Merge "Track sources for srcjars across modules" am: 082640d6ee

am: 222f5ee5f2

Change-Id: I1787ef4d66ebd129a15536b1455139235613ce2c
This commit is contained in:
Colin Cross
2019-05-07 10:43:23 -07:00
committed by android-build-merger
5 changed files with 111 additions and 27 deletions

View File

@@ -481,12 +481,6 @@ func TestResources(t *testing.T) {
}`,
args: "-C java-res -f java-res/a/a -f java-res/b/b",
},
{
// Test that a module with "include_srcs: true" includes its source files in the resources jar
name: "include sources",
prop: `include_srcs: true`,
args: "-C . -f a.java -f b.java -f c.java",
},
{
// Test that a module with wildcards in java_resource_dirs has the correct path prefixes
name: "wildcard dirs",
@@ -555,6 +549,69 @@ func TestResources(t *testing.T) {
}
}
func TestIncludeSrcs(t *testing.T) {
ctx := testJava(t, `
java_library {
name: "foo",
srcs: [
"a.java",
"b.java",
"c.java",
],
include_srcs: true,
}
java_library {
name: "bar",
srcs: [
"a.java",
"b.java",
"c.java",
],
java_resource_dirs: ["java-res"],
include_srcs: true,
}
`)
// Test a library with include_srcs: true
foo := ctx.ModuleForTests("foo", "android_common").Output("withres/foo.jar")
fooSrcJar := ctx.ModuleForTests("foo", "android_common").Output("foo.srcjar")
if g, w := fooSrcJar.Output.String(), foo.Inputs.Strings(); !inList(g, w) {
t.Errorf("foo combined jars %v does not contain %q", w, g)
}
if g, w := fooSrcJar.Args["jarArgs"], "-C . -f a.java -f b.java -f c.java"; g != w {
t.Errorf("foo source jar args %q is not %q", w, g)
}
// Test a library with include_srcs: true and resources
bar := ctx.ModuleForTests("bar", "android_common").Output("withres/bar.jar")
barResCombined := ctx.ModuleForTests("bar", "android_common").Output("res-combined/bar.jar")
barRes := ctx.ModuleForTests("bar", "android_common").Output("res/bar.jar")
barSrcJar := ctx.ModuleForTests("bar", "android_common").Output("bar.srcjar")
if g, w := barSrcJar.Output.String(), barResCombined.Inputs.Strings(); !inList(g, w) {
t.Errorf("bar combined resource jars %v does not contain %q", w, g)
}
if g, w := barRes.Output.String(), barResCombined.Inputs.Strings(); !inList(g, w) {
t.Errorf("bar combined resource jars %v does not contain %q", w, g)
}
if g, w := barResCombined.Output.String(), bar.Inputs.Strings(); !inList(g, w) {
t.Errorf("bar combined jars %v does not contain %q", w, g)
}
if g, w := barSrcJar.Args["jarArgs"], "-C . -f a.java -f b.java -f c.java"; g != w {
t.Errorf("bar source jar args %q is not %q", w, g)
}
if g, w := barRes.Args["jarArgs"], "-C java-res -f java-res/a/a -f java-res/b/b"; g != w {
t.Errorf("bar resource jar args %q is not %q", w, g)
}
}
func TestGeneratedSources(t *testing.T) {
ctx := testJava(t, `
java_library {