Add java_boot_libs to sdk
The build has some implicit dependencies (via the boot jars configuration) on a number of modules, e.g. core-oj, apache-xml, that are part of the java boot class path and which are provided by mainline modules (e.g. art, conscrypt, runtime-i18n) 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. This change adds the java_boot_libs property to allow those modules to be exported as part of the sdk/module_exports without exposing any unnecessary information. Some points to note: * The java_import has to have a valid file for the src property otherwise it will be disabled. * The src property is supposed to reference a jar file but the java_boot_libs property will make it reference an empty file (not an empty jar) so that any attempt to use that file as a jar, e.g. compiling against it, will cause a build failure. * The name of the file passed to the src property should make it clear that the file is not intended to be used. * The test makes sure that only the jar file is copied to the snapshot. Test: m nothing Bug: 171061220 Change-Id: I175331e4c8e3874ab70a67cdc2f76ed1576e41eb
This commit is contained in:
@@ -472,6 +472,61 @@ aidl/foo/bar/Test.aidl -> aidl/aidl/foo/bar/Test.aidl
|
||||
)
|
||||
}
|
||||
|
||||
func TestSnapshotWithJavaBootLibrary(t *testing.T) {
|
||||
result := testSdkWithJava(t, `
|
||||
module_exports {
|
||||
name: "myexports",
|
||||
java_boot_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_boot_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,
|
||||
}
|
||||
`)
|
||||
|
||||
result.CheckSnapshot("myexports", "",
|
||||
checkAndroidBpContents(`
|
||||
// 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_boot_libs/snapshot/jars/are/invalid/myjavalib.jar"],
|
||||
}
|
||||
|
||||
java_import {
|
||||
name: "myjavalib",
|
||||
prefer: false,
|
||||
visibility: ["//visibility:public"],
|
||||
apex_available: ["//apex_available:platform"],
|
||||
jars: ["java_boot_libs/snapshot/jars/are/invalid/myjavalib.jar"],
|
||||
}
|
||||
|
||||
module_exports_snapshot {
|
||||
name: "myexports@current",
|
||||
visibility: ["//visibility:public"],
|
||||
java_boot_libs: ["myexports_myjavalib@current"],
|
||||
}
|
||||
|
||||
`),
|
||||
checkAllCopyRules(`
|
||||
.intermediates/myexports/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/myjavalib.jar
|
||||
`),
|
||||
)
|
||||
}
|
||||
|
||||
func TestHostSnapshotWithJavaImplLibrary(t *testing.T) {
|
||||
result := testSdkWithJava(t, `
|
||||
module_exports {
|
||||
|
Reference in New Issue
Block a user