Provide a resource_prefix_strip for java_resources in bp2build.
Although paths to resource files in a Bazel java_library should be relative to the package, the directory structure in the resulting jar will have resources under the full path from the top-level of the workspace, e.g. if a library in "a/BUILD" has java_resouces as "res/res.txt" then by default the res.txt file would appear under "a/res/res.txt". Fix this by adding a resource_strip_prefix in that case. Test: Unit tests Change-Id: If4325126f5c19a2a8fb83ee09bc3a95a18673fe3
This commit is contained in:
@@ -283,21 +283,25 @@ func TestJavaLibraryLogTags(t *testing.T) {
|
||||
|
||||
func TestJavaLibraryResources(t *testing.T) {
|
||||
runJavaLibraryTestCase(t, Bp2buildTestCase{
|
||||
Dir: "adir",
|
||||
Filesystem: map[string]string{
|
||||
"res/a.res": "",
|
||||
"res/b.res": "",
|
||||
"res/dir1/b.res": "",
|
||||
},
|
||||
Blueprint: `java_library {
|
||||
"adir/res/a.res": "",
|
||||
"adir/res/b.res": "",
|
||||
"adir/res/dir1/b.res": "",
|
||||
"adir/Android.bp": `java_library {
|
||||
name: "java-lib-1",
|
||||
java_resources: ["res/a.res", "res/b.res"],
|
||||
java_resources: ["res/a.res", "res/b.res"],
|
||||
bazel_module: { bp2build_available: true },
|
||||
}`,
|
||||
},
|
||||
Blueprint: "",
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("java_library", "java-lib-1", AttrNameToString{
|
||||
"resources": `[
|
||||
"res/a.res",
|
||||
"res/b.res",
|
||||
]`,
|
||||
"resource_strip_prefix": `"adir"`,
|
||||
}),
|
||||
MakeNeverlinkDuplicateTarget("java_library", "java-lib-1"),
|
||||
},
|
||||
|
Reference in New Issue
Block a user