diff options
| author | 2023-02-03 22:56:13 +0000 | |
|---|---|---|
| committer | 2023-02-04 00:29:33 +0000 | |
| commit | 42b589cd61b06628cde0aa311ab149a066eec8b0 (patch) | |
| tree | be7b2a17bd4c00b9b067b1fdc424e3c21648e822 /java | |
| parent | fd659ef7da3c7f1a787967ac6fa51312cdc88204 (diff) | |
Prevent dynamically created java_api_contribution from inheriting
parent modules' visibility
By default, dynamically created module inherits the parent module's
visibility. When the parent module's visibility is set to
"//visibility:private" or has any other specified visibility
restrictions in the module definition, the created
java_api_contribution module is not visible to java_api_library.
Thus, override any inherited visibility properties and set the visiblity
of the created java_api_contribution module to public.
Test: m
Change-Id: I5db60a5a1800e2ae28c9650eeb9a2f1c3b4f8989
Diffstat (limited to 'java')
| -rw-r--r-- | java/droidstubs.go | 2 | ||||
| -rw-r--r-- | java/droidstubs_test.go | 33 |
2 files changed, 35 insertions, 0 deletions
diff --git a/java/droidstubs.go b/java/droidstubs.go index d9613e536..8a521aabb 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -878,11 +878,13 @@ func (d *Droidstubs) createApiContribution(ctx android.DefaultableHookContext) { Name *string Api_surface *string Api_file *string + Visibility []string }{} props.Name = proptools.StringPtr(d.Name() + ".api.contribution") props.Api_surface = api_surface props.Api_file = api_file + props.Visibility = []string{"//visibility:override", "//visibility:public"} ctx.CreateModule(ApiContributionFactory, &props) } diff --git a/java/droidstubs_test.go b/java/droidstubs_test.go index 6c2293746..7a04d7326 100644 --- a/java/droidstubs_test.go +++ b/java/droidstubs_test.go @@ -370,3 +370,36 @@ func TestDroidStubsApiContributionGeneration(t *testing.T) { ctx.ModuleForTests("foo.api.contribution", "") } + +func TestGeneratedApiContributionVisibilityTest(t *testing.T) { + library_bp := ` + java_api_library { + name: "bar", + api_surface: "public", + api_contributions: ["foo.api.contribution"], + } + ` + ctx, _ := testJavaWithFS(t, ` + droidstubs { + name: "foo", + srcs: ["A/a.java"], + api_surface: "public", + check_api: { + current: { + api_file: "A/current.txt", + removed_api_file: "A/removed.txt", + } + }, + visibility: ["//a"], + } + `, + map[string][]byte{ + "a/a.java": nil, + "a/current.txt": nil, + "a/removed.txt": nil, + "b/Android.bp": []byte(library_bp), + }, + ) + + ctx.ModuleForTests("bar", "android_common") +} |