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:
@@ -96,6 +96,8 @@ func testJava(t *testing.T, bp string) *android.TestContext {
|
|||||||
"b.jar": nil,
|
"b.jar": nil,
|
||||||
"res/a": nil,
|
"res/a": nil,
|
||||||
"res/b": nil,
|
"res/b": nil,
|
||||||
|
"res2/a": nil,
|
||||||
|
|
||||||
"prebuilts/sdk/14/android.jar": nil,
|
"prebuilts/sdk/14/android.jar": nil,
|
||||||
"prebuilts/sdk/14/framework.aidl": 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) {
|
func fail(t *testing.T, errs []error) {
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
for _, err := range errs {
|
for _, err := range errs {
|
||||||
|
@@ -47,7 +47,8 @@ func ResourceDirsToJarArgs(ctx android.ModuleContext,
|
|||||||
var excludes []string
|
var excludes []string
|
||||||
|
|
||||||
for _, exclude := range excludeDirs {
|
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...)
|
excludes = append(excludes, resourceExcludes...)
|
||||||
|
Reference in New Issue
Block a user