Use module-lib system modules when building from prebuilts
When building from source the build uses the java system modules for the public or module APIs as needed. However, previously when building from prebuilts it would always use the public API. That difference lead to build failures when building from prebuilts. This change makes the selection of java system modules when building from prebuilts consistent with the selection when building from sources. As API levels 30 and 31 (which are the only previous releases to provide system modules) did not provide separate java system modules for the module-lib API those levels always use the public APIs. Bug: 204189791 Test: - before applying these change m TARGET_BUILD_APPS=framework-connectivity - build fails with compilation error due to missing module APIs m sdk dist cp out/dist/system-modules/module-lib/core-for-system-modules.jar prebuilts/sdk/current/module-lib/core-for-system-modules.jar - apply these changes m TARGET_BUILD_APPS=framework-connectivity - build passes as expected Change-Id: Id113ff014e7892b1009fbcaad89b1ae23a7c3b79
This commit is contained in:
28
java/sdk.go
28
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)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user