summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
author Romain Jobredeaux <jobredeaux@google.com> 2023-05-04 14:54:45 -0400
committer Romain Jobredeaux <jobredeaux@google.com> 2023-05-04 14:54:45 -0400
commitd5fe1330774ee9e6342b08e371fdefce5c0d6214 (patch)
tree2b29009886f5dc66d66aba7377e97d5d7c0086b9 /java/java.go
parent30208863b4ffdf48bd75549a20d083ef8950c3a2 (diff)
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
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/java/java.go b/java/java.go
index 0da73281b..cb8003dcc 100644
--- a/java/java.go
+++ b/java/java.go
@@ -2707,8 +2707,13 @@ func (m *Library) convertJavaResourcesAttributes(ctx android.TopDownMutatorConte
var resources bazel.LabelList
var resourceStripPrefix *string
+ if m.properties.Java_resources != nil && len(m.properties.Java_resource_dirs) > 0 {
+ ctx.ModuleErrorf("bp2build doesn't support both java_resources and java_resource_dirs being set on the same module.")
+ }
+
if m.properties.Java_resources != nil {
resources.Append(android.BazelLabelForModuleSrc(ctx, m.properties.Java_resources))
+ resourceStripPrefix = proptools.StringPtr(ctx.ModuleDir())
}
//TODO(b/179889880) handle case where glob includes files outside package