diff options
author | Paul Duffin <paulduffin@google.com> | 2021-05-12 13:46:54 +0100 |
---|---|---|
committer | Paul Duffin <paulduffin@google.com> | 2021-05-13 21:25:42 +0100 |
commit | a10bd3c1277dd1fa9ff171ce68d2fdeacbf9609b (patch) | |
tree | f4a14af070a99ebbf64c6d213796f0f7f7faa246 /sdk/bootclasspath_fragment_sdk_test.go | |
parent | 17ccf26748ab80ac2a1ccf55f3426022a1268307 (diff) |
Add java_sdk_library in bootclasspath_fragment contents to sdk
A java_library specified in a bootclasspath_fragment's contents
property will be automatically added to the sdk containing that
bootclasspath_fragment. Previously, if that was attempted with a
java_sdk_library it would be added to the sdk as if it was a normal
java_boot_libs which would prevent the sdk from containing the
API specific artifact such as current.txt files and stub libraries
and sources.
This change fixes that and adds a java_sdk_library as a java_sdk_libs
module.
Bug: 177892522
Test: m nothing
Change-Id: Ided57b846ce5b8940c7e898c786fd77602582ea2
Diffstat (limited to 'sdk/bootclasspath_fragment_sdk_test.go')
-rw-r--r-- | sdk/bootclasspath_fragment_sdk_test.go | 75 |
1 files changed, 68 insertions, 7 deletions
diff --git a/sdk/bootclasspath_fragment_sdk_test.go b/sdk/bootclasspath_fragment_sdk_test.go index f18e69783..cc9a66db0 100644 --- a/sdk/bootclasspath_fragment_sdk_test.go +++ b/sdk/bootclasspath_fragment_sdk_test.go @@ -165,21 +165,33 @@ func TestSnapshotWithBootClasspathFragment_Contents(t *testing.T) { prepareForSdkTestWithJava, java.PrepareForTestWithJavaDefaultModules, java.PrepareForTestWithJavaSdkLibraryFiles, - java.FixtureWithLastReleaseApis("mysdklibrary", "mycoreplatform"), + java.FixtureWithLastReleaseApis("mysdklibrary", "myothersdklibrary", "mycoreplatform"), android.FixtureWithRootAndroidBp(` sdk { name: "mysdk", bootclasspath_fragments: ["mybootclasspathfragment"], - java_sdk_libs: ["mysdklibrary", "mycoreplatform"], + java_sdk_libs: [ + // This is not strictly needed as it should be automatically added to the sdk_snapshot as + // a java_sdk_libs module because it is used in the mybootclasspathfragment's + // api.stub_libs property. However, it is specified here to ensure that duplicates are + // correctly deduped. + "mysdklibrary", + ], } bootclasspath_fragment { name: "mybootclasspathfragment", - contents: ["mybootlib"], + contents: [ + // This should be automatically added to the sdk_snapshot as a java_boot_libs module. + "mybootlib", + // This should be automatically added to the sdk_snapshot as a java_sdk_libs module. + "myothersdklibrary", + ], api: { stub_libs: ["mysdklibrary"], }, core_platform_api: { + // This should be automatically added to the sdk_snapshot as a java_sdk_libs module. stub_libs: ["mycoreplatform"], }, } @@ -200,6 +212,13 @@ func TestSnapshotWithBootClasspathFragment_Contents(t *testing.T) { } java_sdk_library { + name: "myothersdklibrary", + srcs: ["Test.java"], + compile_dex: true, + public: {enabled: true}, + } + + java_sdk_library { name: "mycoreplatform", srcs: ["Test.java"], compile_dex: true, @@ -217,7 +236,10 @@ prebuilt_bootclasspath_fragment { prefer: false, visibility: ["//visibility:public"], apex_available: ["//apex_available:platform"], - contents: ["mybootlib"], + contents: [ + "mybootlib", + "myothersdklibrary", + ], api: { stub_libs: ["mysdklibrary"], }, @@ -235,6 +257,22 @@ java_import { } java_sdk_library_import { + name: "myothersdklibrary", + prefer: false, + visibility: ["//visibility:public"], + apex_available: ["//apex_available:platform"], + shared_library: true, + compile_dex: true, + public: { + jars: ["sdk_library/public/myothersdklibrary-stubs.jar"], + stub_srcs: ["sdk_library/public/myothersdklibrary_stub_sources"], + current_api: "sdk_library/public/myothersdklibrary.txt", + removed_api: "sdk_library/public/myothersdklibrary-removed.txt", + sdk_version: "current", + }, +} + +java_sdk_library_import { name: "mysdklibrary", prefer: false, visibility: ["//visibility:public"], @@ -265,7 +303,7 @@ java_sdk_library_import { sdk_version: "current", }, } -`), + `), checkVersionedAndroidBpContents(` // This is auto-generated. DO NOT EDIT. @@ -274,7 +312,10 @@ prebuilt_bootclasspath_fragment { sdk_member_name: "mybootclasspathfragment", visibility: ["//visibility:public"], apex_available: ["//apex_available:platform"], - contents: ["mysdk_mybootlib@current"], + contents: [ + "mysdk_mybootlib@current", + "mysdk_myothersdklibrary@current", + ], api: { stub_libs: ["mysdk_mysdklibrary@current"], }, @@ -292,6 +333,22 @@ java_import { } java_sdk_library_import { + name: "mysdk_myothersdklibrary@current", + sdk_member_name: "myothersdklibrary", + visibility: ["//visibility:public"], + apex_available: ["//apex_available:platform"], + shared_library: true, + compile_dex: true, + public: { + jars: ["sdk_library/public/myothersdklibrary-stubs.jar"], + stub_srcs: ["sdk_library/public/myothersdklibrary_stub_sources"], + current_api: "sdk_library/public/myothersdklibrary.txt", + removed_api: "sdk_library/public/myothersdklibrary-removed.txt", + sdk_version: "current", + }, +} + +java_sdk_library_import { name: "mysdk_mysdklibrary@current", sdk_member_name: "mysdklibrary", visibility: ["//visibility:public"], @@ -329,13 +386,17 @@ sdk_snapshot { bootclasspath_fragments: ["mysdk_mybootclasspathfragment@current"], java_boot_libs: ["mysdk_mybootlib@current"], java_sdk_libs: [ + "mysdk_myothersdklibrary@current", "mysdk_mysdklibrary@current", "mysdk_mycoreplatform@current", ], } -`), + `), checkAllCopyRules(` .intermediates/mybootlib/android_common/javac/mybootlib.jar -> java/mybootlib.jar +.intermediates/myothersdklibrary.stubs/android_common/javac/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar +.intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt +.intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt |