diff options
author | 2023-02-14 20:18:20 +0000 | |
---|---|---|
committer | 2023-02-15 00:27:18 +0000 | |
commit | e30fff0b5c4a8676fb48f14a813ac238217c8937 (patch) | |
tree | 5f0310aad026cd996883a091bdc46c693db5860d /java/java_test.go | |
parent | d48abd566b80e407adaba600335b1c0e5824081e (diff) |
Add static_libs property in java_api_library soong module
Package private stub annotations are not part of any API surfaces, but
are included in the `android_<API_SURFACE_NAME>_stubs_current`. Since
these cannot be included in the java_api_library by api_contributions,
add static_libs property to statically include jars in the output jar
file.
Test: m
Change-Id: Icb4401f29079ba32df4c192943a7e8814599d9ba
Diffstat (limited to 'java/java_test.go')
-rw-r--r-- | java/java_test.go | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/java/java_test.go b/java/java_test.go index 21993eccf..dc42e9e59 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -2128,6 +2128,80 @@ func TestJavaApiLibraryLibsLink(t *testing.T) { } } +func TestJavaApiLibraryStaticLibsLink(t *testing.T) { + provider_bp_a := ` + java_api_contribution { + name: "foo1", + api_file: "foo1.txt", + } + ` + provider_bp_b := ` + java_api_contribution { + name: "foo2", + api_file: "foo2.txt", + } + ` + lib_bp_a := ` + java_library { + name: "lib1", + srcs: ["Lib.java"], + } + ` + lib_bp_b := ` + java_library { + name: "lib2", + srcs: ["Lib.java"], + } + ` + + ctx, _ := testJavaWithFS(t, ` + java_api_library { + name: "bar1", + api_surface: "public", + api_contributions: ["foo1"], + static_libs: ["lib1"], + } + + java_api_library { + name: "bar2", + api_surface: "system", + api_contributions: ["foo1", "foo2"], + static_libs: ["lib1", "lib2", "bar1"], + } + `, + map[string][]byte{ + "a/Android.bp": []byte(provider_bp_a), + "b/Android.bp": []byte(provider_bp_b), + "c/Android.bp": []byte(lib_bp_a), + "c/Lib.java": {}, + "d/Android.bp": []byte(lib_bp_b), + "d/Lib.java": {}, + }) + + testcases := []struct { + moduleName string + staticLibJarNames []string + }{ + { + moduleName: "bar1", + staticLibJarNames: []string{"lib1.jar"}, + }, + { + moduleName: "bar2", + staticLibJarNames: []string{"lib1.jar", "lib2.jar", "bar1/android.jar"}, + }, + } + for _, c := range testcases { + m := ctx.ModuleForTests(c.moduleName, "android_common") + mergeZipsCommand := m.Rule("merge_zips").RuleParams.Command + for _, jarName := range c.staticLibJarNames { + if !strings.Contains(mergeZipsCommand, jarName) { + t.Errorf("merge_zips command does not contain expected jar %s", jarName) + } + } + } +} + func TestTradefedOptions(t *testing.T) { result := PrepareForTestWithJavaBuildComponents.RunTestWithBp(t, ` java_test_host { |