From 786df93db0d5bab68b7002544454835c3f59ad18 Mon Sep 17 00:00:00 2001 From: Jihoon Kang Date: Thu, 7 Sep 2023 01:18:31 +0000 Subject: Modify static lib stub library visiblity java_sdk_library generates stub java_library module which compiles the stub generated from either source or txt files, which is toggled based on the build configuration. The java_api_library/java_library module that compiles the stubs should not be directly accessible to the modules outside of the sdk_library module scope, thus modify their visibility as private. Test: m nothing Bug: 299373105 Change-Id: Ia4a08bf6e65c521814c82f54ea43cc8d367834e3 --- java/sdk_library_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'java/sdk_library_test.go') diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go index 118f8b68c..868d697ce 100644 --- a/java/sdk_library_test.go +++ b/java/sdk_library_test.go @@ -1474,3 +1474,32 @@ func TestJavaSdkLibrary_ApiLibrary(t *testing.T) { android.AssertStringEquals(t, "Module expected to contain full api surface api library", c.fullApiSurfaceStub, *m.properties.Full_api_surface_stub) } } + +func TestStaticDepStubLibrariesVisibility(t *testing.T) { + android.GroupFixturePreparers( + prepareForJavaTest, + PrepareForTestWithJavaSdkLibraryFiles, + FixtureWithLastReleaseApis("foo"), + android.FixtureMergeMockFs( + map[string][]byte{ + "A.java": nil, + "dir/Android.bp": []byte( + ` + java_library { + name: "bar", + srcs: ["A.java"], + libs: ["foo.stubs.from-source"], + } + `), + "dir/A.java": nil, + }, + ).ExtendWithErrorHandler( + android.FixtureExpectsAtLeastOneErrorMatchingPattern( + `module "bar" variant "android_common": depends on //.:foo.stubs.from-source which is not visible to this module`)), + ).RunTestWithBp(t, ` + java_sdk_library { + name: "foo", + srcs: ["A.java"], + } + `) +} -- cgit v1.2.3-59-g8ed1b