Add test for sdk that contains overlapping members
This change adds a test for an sdk that includes a java_sdk_library directly as well as transitively includes one of the component modules that it creates. It also adds a test for the names of a versioned java_sdk_library_import's components as fixing one requires fixing the other. The use case added is one that does occur in the art-module-sdk. It has a couple of pairs of java_sdk_library and java_system_modules that cause both the java_sdk_library and one of its component modules to be included in the sdk snapshot. That causes problems when building against prebuilts. e.g. The art-module-sdk_art.module.public.api.stubs module is a duplicate of the art.module.public.api.stubs module created by the art.module.public.api java_sdk_library_import. The former is added because the art-module-public-api-stubs-system-modules depends on it. A follow up change will avoid the component being added to the sdk snapshot separately and instead cause the snapshot to use the component created by the java_sdk_library_import in the snapshot. Bug: 179354495 Test: m nothing Merged-In: Ifdc1b4a5a7968db2ded3fdb7eb02f9cff77c7c3f Change-Id: Ifdc1b4a5a7968db2ded3fdb7eb02f9cff77c7c3f (cherry picked from commit 3302871b7d64ea1cfd5c56b7ac76f5c74db4e7fa)
This commit is contained in:
parent
0b5a143c32
commit
0e7bb0e80a
|
@ -663,16 +663,28 @@ module_exports_snapshot {
|
|||
}
|
||||
|
||||
func TestSnapshotWithJavaSystemModules(t *testing.T) {
|
||||
result := android.GroupFixturePreparers(prepareForSdkTestWithJava).RunTestWithBp(t, `
|
||||
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
|
||||
sdk {
|
||||
name: "mysdk",
|
||||
java_header_libs: ["exported-system-module"],
|
||||
java_sdk_libs: ["myjavalib"],
|
||||
java_system_modules: ["my-system-modules"],
|
||||
}
|
||||
|
||||
java_sdk_library {
|
||||
name: "myjavalib",
|
||||
apex_available: ["//apex_available:anyapex"],
|
||||
srcs: ["Test.java"],
|
||||
sdk_version: "current",
|
||||
shared_library: false,
|
||||
public: {
|
||||
enabled: true,
|
||||
},
|
||||
}
|
||||
|
||||
java_system_modules {
|
||||
name: "my-system-modules",
|
||||
libs: ["system-module", "exported-system-module"],
|
||||
libs: ["system-module", "exported-system-module", "myjavalib.stubs"],
|
||||
}
|
||||
|
||||
java_library {
|
||||
|
@ -710,6 +722,29 @@ java_import {
|
|||
jars: ["java/system-module.jar"],
|
||||
}
|
||||
|
||||
java_import {
|
||||
name: "mysdk_myjavalib.stubs",
|
||||
prefer: false,
|
||||
visibility: ["//visibility:private"],
|
||||
apex_available: ["//apex_available:platform"],
|
||||
jars: ["java/myjavalib.stubs.jar"],
|
||||
}
|
||||
|
||||
java_sdk_library_import {
|
||||
name: "myjavalib",
|
||||
prefer: false,
|
||||
visibility: ["//visibility:public"],
|
||||
apex_available: ["//apex_available:anyapex"],
|
||||
shared_library: false,
|
||||
public: {
|
||||
jars: ["sdk_library/public/myjavalib-stubs.jar"],
|
||||
stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
|
||||
current_api: "sdk_library/public/myjavalib.txt",
|
||||
removed_api: "sdk_library/public/myjavalib-removed.txt",
|
||||
sdk_version: "current",
|
||||
},
|
||||
}
|
||||
|
||||
java_system_modules_import {
|
||||
name: "my-system-modules",
|
||||
prefer: false,
|
||||
|
@ -717,6 +752,7 @@ java_system_modules_import {
|
|||
libs: [
|
||||
"mysdk_system-module",
|
||||
"exported-system-module",
|
||||
"mysdk_myjavalib.stubs",
|
||||
],
|
||||
}
|
||||
`),
|
||||
|
@ -739,6 +775,29 @@ java_import {
|
|||
jars: ["java/system-module.jar"],
|
||||
}
|
||||
|
||||
java_import {
|
||||
name: "mysdk_myjavalib.stubs@current",
|
||||
sdk_member_name: "myjavalib.stubs",
|
||||
visibility: ["//visibility:private"],
|
||||
apex_available: ["//apex_available:platform"],
|
||||
jars: ["java/myjavalib.stubs.jar"],
|
||||
}
|
||||
|
||||
java_sdk_library_import {
|
||||
name: "mysdk_myjavalib@current",
|
||||
sdk_member_name: "myjavalib",
|
||||
visibility: ["//visibility:public"],
|
||||
apex_available: ["//apex_available:anyapex"],
|
||||
shared_library: false,
|
||||
public: {
|
||||
jars: ["sdk_library/public/myjavalib-stubs.jar"],
|
||||
stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
|
||||
current_api: "sdk_library/public/myjavalib.txt",
|
||||
removed_api: "sdk_library/public/myjavalib-removed.txt",
|
||||
sdk_version: "current",
|
||||
},
|
||||
}
|
||||
|
||||
java_system_modules_import {
|
||||
name: "mysdk_my-system-modules@current",
|
||||
sdk_member_name: "my-system-modules",
|
||||
|
@ -746,6 +805,7 @@ java_system_modules_import {
|
|||
libs: [
|
||||
"mysdk_system-module@current",
|
||||
"mysdk_exported-system-module@current",
|
||||
"mysdk_myjavalib.stubs@current",
|
||||
],
|
||||
}
|
||||
|
||||
|
@ -753,12 +813,17 @@ sdk_snapshot {
|
|||
name: "mysdk@current",
|
||||
visibility: ["//visibility:public"],
|
||||
java_header_libs: ["mysdk_exported-system-module@current"],
|
||||
java_sdk_libs: ["mysdk_myjavalib@current"],
|
||||
java_system_modules: ["mysdk_my-system-modules@current"],
|
||||
}
|
||||
`),
|
||||
checkAllCopyRules(`
|
||||
.intermediates/exported-system-module/android_common/turbine-combined/exported-system-module.jar -> java/exported-system-module.jar
|
||||
.intermediates/system-module/android_common/turbine-combined/system-module.jar -> java/system-module.jar
|
||||
.intermediates/myjavalib.stubs/android_common/turbine-combined/myjavalib.stubs.jar -> java/myjavalib.stubs.jar
|
||||
.intermediates/myjavalib.stubs/android_common/javac/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
|
||||
.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
|
||||
.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
|
||||
`),
|
||||
)
|
||||
}
|
||||
|
@ -1085,7 +1150,14 @@ sdk_snapshot {
|
|||
checkMergeZips(
|
||||
".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip",
|
||||
".intermediates/mysdk/common_os/tmp/sdk_library/system/myjavalib_stub_sources.zip",
|
||||
".intermediates/mysdk/common_os/tmp/sdk_library/test/myjavalib_stub_sources.zip"),
|
||||
".intermediates/mysdk/common_os/tmp/sdk_library/test/myjavalib_stub_sources.zip",
|
||||
),
|
||||
snapshotTestChecker(checkSnapshotWithoutSource, func(t *testing.T, result *android.TestResult) {
|
||||
// Show that the existing behavior is incorrect as the suffix for the child modules is added
|
||||
// to the version not before it.
|
||||
result.Module("mysdk_myjavalib@current.stubs", "android_common")
|
||||
result.Module("mysdk_myjavalib@current.stubs.source", "android_common")
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue