From 0e73f9ee6db05504a5a586b931645a3da51ed9a8 Mon Sep 17 00:00:00 2001 From: Anton Hansson Date: Wed, 20 Sep 2023 13:39:57 +0000 Subject: Collect transitive source files for java modules This new entry in the JavaInfoProvider lists all the transitive source files contained within the library. That is, the source files of the module and all its static dependencies. Bug: 151360309 Test: unit test in java_go + some manual testing Change-Id: I7fe3035b9e46774095c0e9196cd77fa1027adf6d --- java/java_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'java/java_test.go') diff --git a/java/java_test.go b/java/java_test.go index b555a9513..d51604a25 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -2263,6 +2263,28 @@ func TestJavaApiLibraryFullApiSurfaceStub(t *testing.T) { android.AssertStringDoesContain(t, "Command expected to contain full_api_surface_stub output jar", manifestCommand, "lib1.jar") } +func TestTransitiveSrcFiles(t *testing.T) { + ctx, _ := testJava(t, ` + java_library { + name: "a", + srcs: ["a.java"], + } + java_library { + name: "b", + srcs: ["b.java"], + } + java_library { + name: "c", + srcs: ["c.java"], + libs: ["a"], + static_libs: ["b"], + } + `) + c := ctx.ModuleForTests("c", "android_common").Module() + transitiveSrcFiles := android.Paths(ctx.ModuleProvider(c, JavaInfoProvider).(JavaInfo).TransitiveSrcFiles.ToList()) + android.AssertArrayString(t, "unexpected jar deps", []string{"b.java", "c.java"}, transitiveSrcFiles.Strings()) +} + func TestTradefedOptions(t *testing.T) { result := PrepareForTestWithJavaBuildComponents.RunTestWithBp(t, ` java_test_host { -- cgit v1.2.3-59-g8ed1b