From e840995ac39040b1e6804e5067a5dde11fa85f8c Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Thu, 22 Sep 2022 16:24:46 +0100 Subject: java_sdk_library: Use dist_stem when generating sdk snapshot file names The API finalization process for platform releases copies various files from the apistubs/ dist directory into prebuilts/sdk//... Having them use the same name in both places makes that process simpler. For most modules the name of the file is derived from the name of the module by appending a suffix but unfortunately, for some modules that does not work. e.g. the conscrypt.txt file is produced by the conscrypt.module.public.api module. The dist_stem property was added to java_sdk_library to allow the stem name of the file to differ from the module name. The API finalization process for extension APIs does something similar as it extracts various files from the snapshots and copies them into the appropriate extension API specific directory in prebuilts/sdk/extensions/. Instead of copying files from the apistubs/ dist directory (which is not built for trains) it copies them from sdk snapshots that are built as part of the train. Previously, the sdk snapshot used to derive the name of the files within the snapshot from the name of the module, it ignored the dist_stem property. This change causes it to use the dist_stem property to make it consistent with the apistubs/ dist directory naming. The file name is created in sdkLibrarySdkMemberProperties.AddPropertyToSet() which does not have access to the dist_stem property. So, it has to be supplied in the sdkLibrarySdkMemberProperties instance in the new Stem property. Bug: 248258460 Test: m nothing BUILD_NUMBER=fixed packages/modules/common/build/mainline_modules_sdks.sh --build-release=latest # Ran the previous command before and after and make sure that the # conscrypt, art and icu sdk snapshots use the dist_stem value but # none of the other snapshots are affected. Change-Id: Ied52003de63dcdb86a252a39bb8781f85d51a6ff --- sdk/java_sdk_test.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'sdk/java_sdk_test.go') diff --git a/sdk/java_sdk_test.go b/sdk/java_sdk_test.go index d59883435..51903ce39 100644 --- a/sdk/java_sdk_test.go +++ b/sdk/java_sdk_test.go @@ -889,6 +889,56 @@ java_sdk_library_import { ) } +func TestSnapshotWithJavaSdkLibrary_DistStem(t *testing.T) { + result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, ` + sdk { + name: "mysdk", + java_sdk_libs: ["myjavalib-foo"], + } + + java_sdk_library { + name: "myjavalib-foo", + apex_available: ["//apex_available:anyapex"], + srcs: ["Test.java"], + sdk_version: "current", + shared_library: false, + public: { + enabled: true, + }, + dist_stem: "myjavalib", + } + `) + + CheckSnapshot(t, result, "mysdk", "", + checkAndroidBpContents(` +// This is auto-generated. DO NOT EDIT. + +java_sdk_library_import { + name: "myjavalib-foo", + 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", + }, +} +`), + checkAllCopyRules(` +.intermediates/myjavalib-foo.stubs/android_common/javac/myjavalib-foo.stubs.jar -> sdk_library/public/myjavalib-stubs.jar +.intermediates/myjavalib-foo.stubs.source/android_common/metalava/myjavalib-foo.stubs.source_api.txt -> sdk_library/public/myjavalib.txt +.intermediates/myjavalib-foo.stubs.source/android_common/metalava/myjavalib-foo.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt +`), + checkMergeZips( + ".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip", + ), + ) +} + func TestSnapshotWithJavaSdkLibrary_UseSrcJar(t *testing.T) { result := android.GroupFixturePreparers( prepareForSdkTestWithJavaSdkLibrary, -- cgit v1.2.3-59-g8ed1b