From 428a366703afa0fb48e49be928771cfc967c31c9 Mon Sep 17 00:00:00 2001 From: Romain Jobredeaux Date: Fri, 28 Jan 2022 11:12:52 -0500 Subject: 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 --- java/java.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'java/java.go') 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) + +} -- cgit v1.2.3-59-g8ed1b