Fix excluding resource directories
Using a glob as a path failed the existence check. Append the glob after converting the path to a string. Test: TestExcludeResources in java_test.go Change-Id: Ic1fd40aa283f3b0d59c1c589dbeec411583eddf1
This commit is contained in:
parent
5a727dfa11
commit
0532fb0d4c
|
@ -96,6 +96,8 @@ func testJava(t *testing.T, bp string) *android.TestContext {
|
|||
"b.jar": nil,
|
||||
"res/a": nil,
|
||||
"res/b": nil,
|
||||
"res2/a": nil,
|
||||
|
||||
"prebuilts/sdk/14/android.jar": nil,
|
||||
"prebuilts/sdk/14/framework.aidl": nil,
|
||||
})
|
||||
|
@ -434,6 +436,42 @@ func TestResources(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestExcludeResources(t *testing.T) {
|
||||
ctx := testJava(t, `
|
||||
java_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
java_resource_dirs: ["res", "res2"],
|
||||
exclude_java_resource_dirs: ["res2"],
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "bar",
|
||||
srcs: ["a.java"],
|
||||
java_resources: ["res/*"],
|
||||
exclude_java_resources: ["res/b"],
|
||||
}
|
||||
`)
|
||||
|
||||
fooRes := ctx.ModuleForTests("foo", "android_common").Output("res.jar")
|
||||
|
||||
expected := "-C res -l " + fooRes.Implicits[0].String()
|
||||
if fooRes.Args["jarArgs"] != expected {
|
||||
t.Errorf("foo resource jar args %q is not %q",
|
||||
fooRes.Args["jarArgs"], expected)
|
||||
|
||||
}
|
||||
|
||||
barRes := ctx.ModuleForTests("bar", "android_common").Output("res.jar")
|
||||
|
||||
expected = "-C . -f res/a"
|
||||
if barRes.Args["jarArgs"] != expected {
|
||||
t.Errorf("bar resource jar args %q is not %q",
|
||||
barRes.Args["jarArgs"], expected)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func fail(t *testing.T, errs []error) {
|
||||
if len(errs) > 0 {
|
||||
for _, err := range errs {
|
||||
|
|
|
@ -47,7 +47,8 @@ func ResourceDirsToJarArgs(ctx android.ModuleContext,
|
|||
var excludes []string
|
||||
|
||||
for _, exclude := range excludeDirs {
|
||||
excludes = append(excludes, android.PathForModuleSrc(ctx, exclude, "**/*").String())
|
||||
excludes = append(excludes,
|
||||
filepath.Join(android.PathForModuleSrc(ctx, exclude).String(), "**/*"))
|
||||
}
|
||||
|
||||
excludes = append(excludes, resourceExcludes...)
|
||||
|
|
Loading…
Reference in New Issue