Add a new SDK member type java_systemserver_libs.
Similar to java_boot_libs, java_systemserver_libs only provide access to their dex implementation jar for use by dexpreopting and do not provide an actual implementation jar. This is used in the subsequent CL. Bug: 194150908 Test: m nothing Change-Id: Ib2e7d5e6c002314a0231f46934a766f4a27e610a
This commit is contained in:
32
java/java.go
32
java/java.go
@@ -73,6 +73,7 @@ func RegisterJavaSdkMemberTypes() {
|
||||
android.RegisterSdkMemberType(javaHeaderLibsSdkMemberType)
|
||||
android.RegisterSdkMemberType(javaLibsSdkMemberType)
|
||||
android.RegisterSdkMemberType(javaBootLibsSdkMemberType)
|
||||
android.RegisterSdkMemberType(javaSystemserverLibsSdkMemberType)
|
||||
android.RegisterSdkMemberType(javaTestSdkMemberType)
|
||||
}
|
||||
|
||||
@@ -146,6 +147,37 @@ var (
|
||||
onlyCopyJarToSnapshot,
|
||||
}
|
||||
|
||||
// Supports adding java systemserver libraries to module_exports and sdk.
|
||||
//
|
||||
// The build has some implicit dependencies (via the systemserver jars configuration) on a number
|
||||
// of modules that are part of the java systemserver classpath and which are provided by mainline
|
||||
// modules but which are not otherwise used outside those mainline modules.
|
||||
//
|
||||
// As they are not needed outside the mainline modules adding them to the sdk/module-exports as
|
||||
// either java_libs, or java_header_libs would end up exporting more information than was strictly
|
||||
// necessary. The java_systemserver_libs property to allow those modules to be exported as part of
|
||||
// the sdk/module_exports without exposing any unnecessary information.
|
||||
javaSystemserverLibsSdkMemberType = &librarySdkMemberType{
|
||||
android.SdkMemberTypeBase{
|
||||
PropertyName: "java_systemserver_libs",
|
||||
SupportsSdk: true,
|
||||
},
|
||||
func(ctx android.SdkMemberContext, j *Library) android.Path {
|
||||
// Java systemserver libs are only provided in the SDK to provide access to their dex
|
||||
// implementation jar for use by dexpreopting. They do not need to provide an actual
|
||||
// implementation jar but the java_import will need a file that exists so just copy an empty
|
||||
// file. Any attempt to use that file as a jar will cause a build error.
|
||||
return ctx.SnapshotBuilder().EmptyFile()
|
||||
},
|
||||
func(osPrefix, name string) string {
|
||||
// Create a special name for the implementation jar to try and provide some useful information
|
||||
// to a developer that attempts to compile against this.
|
||||
// TODO(b/175714559): Provide a proper error message in Soong not ninja.
|
||||
return filepath.Join(osPrefix, "java_systemserver_libs", "snapshot", "jars", "are", "invalid", name+jarFileSuffix)
|
||||
},
|
||||
onlyCopyJarToSnapshot,
|
||||
}
|
||||
|
||||
// Supports adding java test libraries to module_exports but not sdk.
|
||||
javaTestSdkMemberType = &testSdkMemberType{
|
||||
SdkMemberTypeBase: android.SdkMemberTypeBase{
|
||||
|
@@ -482,6 +482,71 @@ module_exports_snapshot {
|
||||
)
|
||||
}
|
||||
|
||||
func TestSnapshotWithJavaSystemserverLibrary(t *testing.T) {
|
||||
result := android.GroupFixturePreparers(
|
||||
prepareForSdkTestWithJava,
|
||||
android.FixtureAddFile("aidl", nil),
|
||||
android.FixtureAddFile("resource.txt", nil),
|
||||
).RunTestWithBp(t, `
|
||||
module_exports {
|
||||
name: "myexports",
|
||||
java_systemserver_libs: ["myjavalib"],
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "myjavalib",
|
||||
srcs: ["Test.java"],
|
||||
java_resources: ["resource.txt"],
|
||||
// The aidl files should not be copied to the snapshot because a java_systemserver_libs member
|
||||
// is not intended to be used for compiling Java, only for accessing the dex implementation
|
||||
// jar.
|
||||
aidl: {
|
||||
export_include_dirs: ["aidl"],
|
||||
},
|
||||
system_modules: "none",
|
||||
sdk_version: "none",
|
||||
compile_dex: true,
|
||||
permitted_packages: ["pkg.myjavalib"],
|
||||
}
|
||||
`)
|
||||
|
||||
CheckSnapshot(t, result, "myexports", "",
|
||||
checkUnversionedAndroidBpContents(`
|
||||
// This is auto-generated. DO NOT EDIT.
|
||||
|
||||
java_import {
|
||||
name: "myjavalib",
|
||||
prefer: false,
|
||||
visibility: ["//visibility:public"],
|
||||
apex_available: ["//apex_available:platform"],
|
||||
jars: ["java_systemserver_libs/snapshot/jars/are/invalid/myjavalib.jar"],
|
||||
permitted_packages: ["pkg.myjavalib"],
|
||||
}
|
||||
`),
|
||||
checkVersionedAndroidBpContents(`
|
||||
// This is auto-generated. DO NOT EDIT.
|
||||
|
||||
java_import {
|
||||
name: "myexports_myjavalib@current",
|
||||
sdk_member_name: "myjavalib",
|
||||
visibility: ["//visibility:public"],
|
||||
apex_available: ["//apex_available:platform"],
|
||||
jars: ["java_systemserver_libs/snapshot/jars/are/invalid/myjavalib.jar"],
|
||||
permitted_packages: ["pkg.myjavalib"],
|
||||
}
|
||||
|
||||
module_exports_snapshot {
|
||||
name: "myexports@current",
|
||||
visibility: ["//visibility:public"],
|
||||
java_systemserver_libs: ["myexports_myjavalib@current"],
|
||||
}
|
||||
`),
|
||||
checkAllCopyRules(`
|
||||
.intermediates/myexports/common_os/empty -> java_systemserver_libs/snapshot/jars/are/invalid/myjavalib.jar
|
||||
`),
|
||||
)
|
||||
}
|
||||
|
||||
func TestHostSnapshotWithJavaImplLibrary(t *testing.T) {
|
||||
result := android.GroupFixturePreparers(
|
||||
prepareForSdkTestWithJava,
|
||||
|
Reference in New Issue
Block a user