diff options
| author | 2021-11-03 15:32:42 +0000 | |
|---|---|---|
| committer | 2021-11-03 15:32:42 +0000 | |
| commit | 8380ee66a590e468daa5efe2855c46c57e4eed84 (patch) | |
| tree | 3b5551d3b50a7653ca669c314ede83887624e47e /java/sdk.go | |
| parent | 5506c1658c654c8d97c6e7f41116678384e2e50b (diff) | |
| parent | 004547facd2b7d95cbd757a7bb076ac1c1b82ab9 (diff) | |
Merge "Use module-lib system modules when building from prebuilts"
Diffstat (limited to 'java/sdk.go')
| -rw-r--r-- | java/sdk.go | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/java/sdk.go b/java/sdk.go index 42ed14f74..34d68aee1 100644 --- a/java/sdk.go +++ b/java/sdk.go @@ -60,10 +60,28 @@ func defaultJavaLanguageVersion(ctx android.EarlyModuleContext, s android.SdkSpe } } -// systemModuleKind returns the kind of system modules to use. -func systemModuleKind() android.SdkKind { - // Currently, every sdk version uses the system modules for the public API. - return android.SdkPublic +// systemModuleKind returns the kind of system modules to use for the supplied combination of sdk +// kind and API level. +func systemModuleKind(sdkKind android.SdkKind, apiLevel android.ApiLevel) android.SdkKind { + systemModuleKind := sdkKind + if apiLevel.LessThanOrEqualTo(android.LastWithoutModuleLibCoreSystemModules) { + // API levels less than or equal to 31 did not provide a core-for-system-modules.jar + // specifically for the module-lib API. So, always use the public system modules for them. + systemModuleKind = android.SdkPublic + } else if systemModuleKind == android.SdkCore { + // Core is by definition what is included in the system module for the public API so should + // just use its system modules. + systemModuleKind = android.SdkPublic + } else if systemModuleKind == android.SdkSystem || systemModuleKind == android.SdkTest { + // The core system and test APIs are currently the same as the public API so they should use + // its system modules. + systemModuleKind = android.SdkPublic + } else if systemModuleKind == android.SdkSystemServer { + // The core system server API is the same as the core module-lib API. + systemModuleKind = android.SdkModule + } + + return systemModuleKind } func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext) sdkDep { @@ -111,7 +129,7 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext) var systemModules string if defaultJavaLanguageVersion(ctx, sdkVersion).usesJavaModules() { - systemModuleKind := systemModuleKind() + systemModuleKind := systemModuleKind(sdkVersion.Kind, sdkVersion.ApiLevel) systemModules = fmt.Sprintf("sdk_%s_%s_system_modules", systemModuleKind, sdkVersion.ApiLevel) } |