diff --git a/android/bazel.go b/android/bazel.go index fafb68b0c..e3fb0a648 100644 --- a/android/bazel.go +++ b/android/bazel.go @@ -570,12 +570,9 @@ var ( "art-script", // depends on unconverted modules: dalvikvm, dex2oat "dex2oat-script", // depends on unconverted modules: dex2oat - "prebuilt_car-ui-androidx-core-common", // b/224773339, genrule dependency creates an .aar, not a .jar - "prebuilt_art-module-host-exports_okhttp-norepackage@current", // aosp/1999250, needs Jars (arch variant) - "prebuilt_conscrypt-unbundled", // aosp/1999250, needs Jars (arch variant) - "prebuilt_conscrypt-module-host-exports_conscrypt-unbundled@current", // aosp/1999250, needs Jars (arch variant) - "prebuilt_platform-robolectric-4.4-prebuilt", // aosp/1999250, needs .aar support in Jars - "prebuilt_platform-robolectric-4.5.1-prebuilt", // aosp/1999250, needs .aar support in Jars + "prebuilt_car-ui-androidx-core-common", // b/224773339, genrule dependency creates an .aar, not a .jar + "prebuilt_platform-robolectric-4.4-prebuilt", // aosp/1999250, needs .aar support in Jars + "prebuilt_platform-robolectric-4.5.1-prebuilt", // aosp/1999250, needs .aar support in Jars } // Per-module denylist of cc_library modules to only generate the static diff --git a/bp2build/java_import_conversion_test.go b/bp2build/java_import_conversion_test.go index 2f7211ccc..0b3191c32 100644 --- a/bp2build/java_import_conversion_test.go +++ b/bp2build/java_import_conversion_test.go @@ -29,7 +29,7 @@ func runJavaImportTestCase(t *testing.T, tc bp2buildTestCase) { func registerJavaImportModuleTypes(ctx android.RegistrationContext) { } -func TestMinimalJavaImport(t *testing.T) { +func TestJavaImportMinimal(t *testing.T) { runJavaImportTestCase(t, bp2buildTestCase{ description: "Java import - simple example", moduleTypeUnderTest: "java_import", @@ -50,3 +50,36 @@ java_import { }), }}) } + +func TestJavaImportArchVariant(t *testing.T) { + runJavaImportTestCase(t, bp2buildTestCase{ + description: "Java import - simple example", + moduleTypeUnderTest: "java_import", + moduleTypeUnderTestFactory: java.ImportFactory, + filesystem: map[string]string{ + "import.jar": "", + }, + blueprint: ` +java_import { + name: "example_import", + target: { + android: { + jars: ["android.jar"], + }, + linux_glibc: { + jars: ["linux.jar"], + }, + }, + bazel_module: { bp2build_available: true }, +} +`, + expectedBazelTargets: []string{ + makeBazelTarget("java_import", "example_import", attrNameToString{ + "jars": `select({ + "//build/bazel/platforms/os:android": ["android.jar"], + "//build/bazel/platforms/os:linux": ["linux.jar"], + "//conditions:default": [], + })`, + }), + }}) +} diff --git a/java/java.go b/java/java.go index 1b6e559b3..ecbbc329c 100644 --- a/java/java.go +++ b/java/java.go @@ -2218,8 +2218,16 @@ type bazelJavaImportAttributes struct { // 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))) + var jars bazel.LabelListAttribute + archVariantProps := i.GetArchVariantProperties(ctx, &ImportProperties{}) + for axis, configToProps := range archVariantProps { + for config, _props := range configToProps { + if archProps, ok := _props.(*ImportProperties); ok { + archJars := android.BazelLabelForModuleSrcExcludes(ctx, archProps.Jars, []string(nil)) + jars.SetSelectValue(axis, config, archJars) + } + } + } attrs := &bazelJavaImportAttributes{ Jars: jars,