aboutsummaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
authorRomain Jobredeaux <jobredeaux@google.com>2022-01-28 11:12:52 -0500
committerRomain Jobredeaux <jobredeaux@google.com>2022-01-29 09:44:37 -0500
commit428a366703afa0fb48e49be928771cfc967c31c9 (patch)
tree114c46798e56aa43bcf3eb111214d763684c1de9 /java/java.go
parent0107901dececd5466d8abc601adb11d4b5a9d0ee (diff)
Basic bp2build converter for java_import.
This only supports the `jars` property/attribute. Test: b build external/error_prone:error_prone_core_jars Bug: 215229744 Change-Id: If0d9c8c4e9c1c560d35a501c20bef9361ef45e15
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)
+
+}