Remove duplicate component from sdk snapshot

Previously, an sdk snapshot could contain the following:
* A java_sdk_library_import module, e.g. "foo" which creates component
  modules "foo.stubs", etc.
* A corresponding versioned module, e.g. "sdk_foo@current" which
  created component modules "sdk_foo@current.stubs", etc.
* An internal (to the sdk snapshot) java_import for one of "foo"'s
  components, e.g. "sdk_foo.stubs"
* A corresponding versioned module, e.g. "sdk_foo.stubs@current".

That causes a few problems:
1. The "foo.stubs" is duplicated.
2. The names of the components created by the versioned
   java_sdk_library_import are invalid, as they append the component's
   suffix to the version and not the name before the version.

The latter causes problems when building against prebuilts and fixing
that causes the generated snapshot to be invalid because it contains
duplicate definitions of the "sdk_foo.stubs@current" module. One
explicitly in the Android.bp file and one created by the
"sdk_foo@current" module.

Removing the duplicates from the snapshot causes errors as the name
generated by the snapshot for the component module, i.e.
"sdk_foo.stubs@current" does not match the name generated by the
"sdk_foo@current", i.e. "sdk_foo@current.stubs".

This change fixes them together.

Bug: 179354495
Test: m nothing
Change-Id: I515f235fe21755b5275af12366e96c24c94c0273
This commit is contained in:
Paul Duffin
2021-04-29 21:50:40 +01:00
parent 3accbb5446
commit a1aa7387f7
5 changed files with 195 additions and 45 deletions

View File

@@ -722,14 +722,6 @@ 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,
@@ -752,7 +744,7 @@ java_system_modules_import {
libs: [
"mysdk_system-module",
"exported-system-module",
"mysdk_myjavalib.stubs",
"myjavalib.stubs",
],
}
`),
@@ -775,14 +767,6 @@ 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",
@@ -820,7 +804,6 @@ sdk_snapshot {
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
@@ -1153,10 +1136,10 @@ sdk_snapshot {
".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")
// Make sure that the name of the child modules created by a versioned java_sdk_library_import
// module is correct, i.e. the suffix is added before the version and not after.
result.Module("mysdk_myjavalib.stubs@current", "android_common")
result.Module("mysdk_myjavalib.stubs.source@current", "android_common")
}),
)
}