summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
author Alix Espino <agespino@google.com> 2023-05-26 13:59:42 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2023-05-26 13:59:42 +0000
commite5641c51b91105be85f9a97ea2a55bba6f84bc0a (patch)
tree714b7f42faeeb6d6df27270e80dcd842a662b229 /java/java.go
parent8321c1a8fbeb88b338bd9f74d35bf4ee5770d0a2 (diff)
parentb29a3cd2aa7d415f4d5f27a775cfb2e02cbe0ba0 (diff)
Merge "bp2build java_resources that only contain a filegroup"
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/java/java.go b/java/java.go
index 74c6c99c0..aa9f936d0 100644
--- a/java/java.go
+++ b/java/java.go
@@ -2704,6 +2704,15 @@ type javaResourcesAttributes struct {
Resource_strip_prefix *string
}
+func (m *Library) javaResourcesGetSingleFilegroupStripPrefix(ctx android.TopDownMutatorContext) (string, bool) {
+ if otherM, ok := ctx.ModuleFromName(m.properties.Java_resources[0]); ok && len(m.properties.Java_resources) == 1 {
+ if fg, isFilegroup := otherM.(android.FileGroupPath); isFilegroup {
+ return filepath.Join(ctx.OtherModuleDir(otherM), fg.GetPath(ctx)), true
+ }
+ }
+ return "", false
+}
+
func (m *Library) convertJavaResourcesAttributes(ctx android.TopDownMutatorContext) *javaResourcesAttributes {
var resources bazel.LabelList
var resourceStripPrefix *string
@@ -2713,8 +2722,12 @@ func (m *Library) convertJavaResourcesAttributes(ctx android.TopDownMutatorConte
}
if m.properties.Java_resources != nil {
+ if prefix, ok := m.javaResourcesGetSingleFilegroupStripPrefix(ctx); ok {
+ resourceStripPrefix = proptools.StringPtr(prefix)
+ } else {
+ resourceStripPrefix = proptools.StringPtr(ctx.ModuleDir())
+ }
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