summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
author Romain Jobredeaux <jobredeaux@google.com> 2022-01-29 20:05:08 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2022-01-29 20:05:08 +0000
commitea64e62dab0fa0a62ed1390546c2bdecd777e7b1 (patch)
treea0a820de2e1f5b39768075c60702b76fa518bbbf /java/java.go
parentb3af19caa2bb241cc4243d26973063f2ca3a6df0 (diff)
parent428a366703afa0fb48e49be928771cfc967c31c9 (diff)
Merge "Basic bp2build converter for java_import."
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/java/java.go b/java/java.go
index 171415207..ca4b3cf41 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1328,6 +1328,7 @@ type Import struct {
android.ModuleBase
android.DefaultableModuleBase
android.ApexModuleBase
+ android.BazelModuleBase
prebuilt android.Prebuilt
android.SdkBase
@@ -1683,6 +1684,7 @@ func ImportFactory() android.Module {
android.InitPrebuiltModule(module, &module.properties.Jars)
android.InitApexModule(module)
android.InitSdkAwareModule(module)
+ android.InitBazelModule(module)
InitJavaModule(module, android.HostAndDeviceSupported)
return module
}
@@ -2101,3 +2103,21 @@ func javaBinaryHostBp2Build(ctx android.TopDownMutatorContext, m *Binary) {
// Create the BazelTargetModule.
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: m.Name()}, attrs)
}
+
+type bazelJavaImportAttributes struct {
+ Jars bazel.LabelListAttribute
+}
+
+// java_import bp2Build converter.
+func (i *Import) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
+ //TODO(b/209577426): Support multiple arch variants
+ jars := bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrcExcludes(ctx, i.properties.Jars, []string(nil)))
+
+ attrs := &bazelJavaImportAttributes{
+ Jars: jars,
+ }
+ props := bazel.BazelTargetModuleProperties{Rule_class: "java_import"}
+
+ ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: android.RemoveOptionalPrebuiltPrefix(i.Name())}, attrs)
+
+}