Loading java/sdk_library.go +12 −5 Original line number Diff line number Diff line Loading @@ -2482,11 +2482,18 @@ func (s *sdkLibrarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberCo } scopeSet.AddProperty("jars", jars) if ctx.SdkModuleContext().Config().IsEnvTrue("SOONG_SDK_SNAPSHOT_USE_SRCJAR") { // Copy the stubs source jar into the snapshot zip as is. srcJarSnapshotPath := filepath.Join(scopeDir, ctx.Name()+".srcjar") ctx.SnapshotBuilder().CopyToSnapshot(properties.StubsSrcJar, srcJarSnapshotPath) scopeSet.AddProperty("stub_srcs", []string{srcJarSnapshotPath}) } else { // Merge the stubs source jar into the snapshot zip so that when it is unpacked // the source files are also unpacked. snapshotRelativeDir := filepath.Join(scopeDir, ctx.Name()+"_stub_sources") ctx.SnapshotBuilder().UnzipToSnapshot(properties.StubsSrcJar, snapshotRelativeDir) scopeSet.AddProperty("stub_srcs", []string{snapshotRelativeDir}) } if properties.CurrentApiFile != nil { currentApiSnapshotPath := filepath.Join(scopeDir, ctx.Name()+".txt") Loading sdk/java_sdk_test.go +51 −0 Original line number Diff line number Diff line Loading @@ -1089,6 +1089,57 @@ sdk_snapshot { ) } func TestSnapshotWithJavaSdkLibrary_UseSrcJar(t *testing.T) { result := android.GroupFixturePreparers( prepareForSdkTestWithJavaSdkLibrary, android.FixtureMergeEnv(map[string]string{ "SOONG_SDK_SNAPSHOT_USE_SRCJAR": "true", }), ).RunTestWithBp(t, ` sdk { name: "mysdk", java_sdk_libs: ["myjavalib"], } java_sdk_library { name: "myjavalib", srcs: ["Test.java"], sdk_version: "current", shared_library: false, public: { enabled: true, }, } `) CheckSnapshot(t, result, "mysdk", "", checkUnversionedAndroidBpContents(` // This is auto-generated. DO NOT EDIT. java_sdk_library_import { name: "myjavalib", prefer: false, visibility: ["//visibility:public"], apex_available: ["//apex_available:platform"], shared_library: false, public: { jars: ["sdk_library/public/myjavalib-stubs.jar"], stub_srcs: ["sdk_library/public/myjavalib.srcjar"], current_api: "sdk_library/public/myjavalib.txt", removed_api: "sdk_library/public/myjavalib-removed.txt", sdk_version: "current", }, } `), checkAllCopyRules(` .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-stubs.srcjar -> sdk_library/public/myjavalib.srcjar .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 `), ) } func TestSnapshotWithJavaSdkLibrary_CompileDex(t *testing.T) { result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, ` sdk { Loading Loading
java/sdk_library.go +12 −5 Original line number Diff line number Diff line Loading @@ -2482,11 +2482,18 @@ func (s *sdkLibrarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberCo } scopeSet.AddProperty("jars", jars) if ctx.SdkModuleContext().Config().IsEnvTrue("SOONG_SDK_SNAPSHOT_USE_SRCJAR") { // Copy the stubs source jar into the snapshot zip as is. srcJarSnapshotPath := filepath.Join(scopeDir, ctx.Name()+".srcjar") ctx.SnapshotBuilder().CopyToSnapshot(properties.StubsSrcJar, srcJarSnapshotPath) scopeSet.AddProperty("stub_srcs", []string{srcJarSnapshotPath}) } else { // Merge the stubs source jar into the snapshot zip so that when it is unpacked // the source files are also unpacked. snapshotRelativeDir := filepath.Join(scopeDir, ctx.Name()+"_stub_sources") ctx.SnapshotBuilder().UnzipToSnapshot(properties.StubsSrcJar, snapshotRelativeDir) scopeSet.AddProperty("stub_srcs", []string{snapshotRelativeDir}) } if properties.CurrentApiFile != nil { currentApiSnapshotPath := filepath.Join(scopeDir, ctx.Name()+".txt") Loading
sdk/java_sdk_test.go +51 −0 Original line number Diff line number Diff line Loading @@ -1089,6 +1089,57 @@ sdk_snapshot { ) } func TestSnapshotWithJavaSdkLibrary_UseSrcJar(t *testing.T) { result := android.GroupFixturePreparers( prepareForSdkTestWithJavaSdkLibrary, android.FixtureMergeEnv(map[string]string{ "SOONG_SDK_SNAPSHOT_USE_SRCJAR": "true", }), ).RunTestWithBp(t, ` sdk { name: "mysdk", java_sdk_libs: ["myjavalib"], } java_sdk_library { name: "myjavalib", srcs: ["Test.java"], sdk_version: "current", shared_library: false, public: { enabled: true, }, } `) CheckSnapshot(t, result, "mysdk", "", checkUnversionedAndroidBpContents(` // This is auto-generated. DO NOT EDIT. java_sdk_library_import { name: "myjavalib", prefer: false, visibility: ["//visibility:public"], apex_available: ["//apex_available:platform"], shared_library: false, public: { jars: ["sdk_library/public/myjavalib-stubs.jar"], stub_srcs: ["sdk_library/public/myjavalib.srcjar"], current_api: "sdk_library/public/myjavalib.txt", removed_api: "sdk_library/public/myjavalib-removed.txt", sdk_version: "current", }, } `), checkAllCopyRules(` .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-stubs.srcjar -> sdk_library/public/myjavalib.srcjar .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 `), ) } func TestSnapshotWithJavaSdkLibrary_CompileDex(t *testing.T) { result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, ` sdk { Loading