From 4ec24870e03eee77911d787d6d160e2389fc2a9f Mon Sep 17 00:00:00 2001 From: Jihoon Kang Date: Thu, 5 Oct 2023 17:26:09 +0000 Subject: Introduce system_modules property to java_api_library System_modules property provides the jars passed as bootclasspath when compiling the stubs in the java_api_library where its creating java_sdk_library's sdk_version is none, as the jars will not be provided from the full_surface_stub_libs but compiled by itself in the child change. The jar provided by the system_modules will also be passed to metalava to resolve hierarchy coming from outer dependencies. Test: m --build-from-text-stub Bug: 288624417 Change-Id: I8f3b89efa24bceb070d7a37fae3c7334dd7f0868 --- java/java_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'java/java_test.go') diff --git a/java/java_test.go b/java/java_test.go index d51604a25..6b8b735f7 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -2447,3 +2447,39 @@ func TestJavaApiLibraryApiFilesSorting(t *testing.T) { "default/java/api/module-lib-current.txt default/java/api/system-server-current.txt" android.AssertStringDoesContain(t, "source text files not in api scope order", manifestCommand, sourceFilesFlag) } + +func TestSdkLibraryProvidesSystemModulesToApiLibrary(t *testing.T) { + result := android.GroupFixturePreparers( + prepareForJavaTest, + PrepareForTestWithJavaSdkLibraryFiles, + FixtureWithLastReleaseApis("foo"), + android.FixtureModifyConfig(func(config android.Config) { + config.SetApiLibraries([]string{"foo"}) + }), + android.FixtureMergeMockFs( + map[string][]byte{ + "A.java": nil, + }, + ), + ).RunTestWithBp(t, ` + java_library { + name: "bar", + srcs: ["a.java"], + } + java_system_modules { + name: "baz", + libs: ["bar"], + } + java_sdk_library { + name: "foo", + srcs: ["A.java"], + system_modules: "baz", + } + `) + m := result.ModuleForTests(apiScopePublic.apiLibraryModuleName("foo"), "android_common") + manifest := m.Output("metalava.sbox.textproto") + sboxProto := android.RuleBuilderSboxProtoForTests(t, manifest) + manifestCommand := sboxProto.Commands[0].GetCommand() + classPathFlag := "--classpath __SBOX_SANDBOX_DIR__/out/.intermediates/bar/android_common/turbine-combined/bar.jar" + android.AssertStringDoesContain(t, "command expected to contain classpath flag", manifestCommand, classPathFlag) +} -- cgit v1.2.3-59-g8ed1b