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
This commit is contained in:
Anton Hansson
2023-09-20 13:39:57 +00:00
parent 2863e4535e
commit 0e73f9ee6d
3 changed files with 46 additions and 0 deletions

View File

@@ -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 {