From 4d56abf9375f6b6b0f945bfd725036c19e8d08a7 Mon Sep 17 00:00:00 2001 From: Alix Date: Thu, 23 Feb 2023 16:38:12 +0000 Subject: resource_strip_prefix support for kotlin srcs change load locations for kt_jvm_library to be the macro Change-Id: Id50fcb1f880013fe57647a065cd6b7149d7c5d91 Test: built kotlinx_coroutines locally and compared jar file to soong Bug: 268519061 --- java/java.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'java/java.go') diff --git a/java/java.go b/java/java.go index a00e26f83..574709169 100644 --- a/java/java.go +++ b/java/java.go @@ -2838,7 +2838,7 @@ func javaLibraryBp2Build(ctx android.TopDownMutatorContext, m *Library) { props = bazel.BazelTargetModuleProperties{ Rule_class: "kt_jvm_library", - Bzl_load_location: "@rules_kotlin//kotlin:jvm_library.bzl", + Bzl_load_location: "//build/bazel/rules/kotlin:kt_jvm_library.bzl", } } @@ -2933,7 +2933,7 @@ func javaBinaryHostBp2Build(ctx android.TopDownMutatorContext, m *Binary) { ktName := m.Name() + "_kt" ktProps := bazel.BazelTargetModuleProperties{ Rule_class: "kt_jvm_library", - Bzl_load_location: "@rules_kotlin//kotlin:jvm_library.bzl", + Bzl_load_location: "//build/bazel/rules/kotlin:kt_jvm_library.bzl", } ktAttrs := &javaLibraryAttributes{ Deps: deps, -- cgit v1.2.3-59-g8ed1b From 5afd9fad98f5a30edae4f8f23044d4be6ab73fc6 Mon Sep 17 00:00:00 2001 From: Alix Date: Fri, 3 Mar 2023 19:22:15 +0000 Subject: code cleanup for bp2build java_binary with kt srcs there is now support for resoure_strip_prefix in kt_jvm_library targets. Test: built AnalyzerKt and updated go ./bp2build tests Change-Id: I4a6fe45276d45519186b6f40a02db990511d6def --- bp2build/java_binary_host_conversion_test.go | 10 +++++----- java/java.go | 20 ++++---------------- 2 files changed, 9 insertions(+), 21 deletions(-) (limited to 'java/java.go') diff --git a/bp2build/java_binary_host_conversion_test.go b/bp2build/java_binary_host_conversion_test.go index 46105c72b..6f17e346f 100644 --- a/bp2build/java_binary_host_conversion_test.go +++ b/bp2build/java_binary_host_conversion_test.go @@ -221,6 +221,11 @@ func TestJavaBinaryHostKotlinWithResourceDir(t *testing.T) { "a.java", "b.kt", ]`, + "resources": `[ + "res/a.res", + "res/dir1/b.res", + ]`, + "resource_strip_prefix": `"res"`, "target_compatible_with": `select({ "//build/bazel/platforms/os:android": ["@platforms//:incompatible"], "//conditions:default": [], @@ -229,11 +234,6 @@ func TestJavaBinaryHostKotlinWithResourceDir(t *testing.T) { MakeBazelTarget("java_binary", "java-binary-host", AttrNameToString{ "main_class": `"com.android.test.MainClass"`, "runtime_deps": `[":java-binary-host_kt"]`, - "resources": `[ - "res/a.res", - "res/dir1/b.res", - ]`, - "resource_strip_prefix": `"res"`, "target_compatible_with": `select({ "//build/bazel/platforms/os:android": ["@platforms//:incompatible"], "//conditions:default": [], diff --git a/java/java.go b/java/java.go index 574709169..6a764cfe9 100644 --- a/java/java.go +++ b/java/java.go @@ -2938,9 +2938,10 @@ func javaBinaryHostBp2Build(ctx android.TopDownMutatorContext, m *Binary) { ktAttrs := &javaLibraryAttributes{ Deps: deps, javaCommonAttributes: &javaCommonAttributes{ - Srcs: commonAttrs.Srcs, - Plugins: commonAttrs.Plugins, - Javacopts: commonAttrs.Javacopts, + Srcs: commonAttrs.Srcs, + Plugins: commonAttrs.Plugins, + Javacopts: commonAttrs.Javacopts, + javaResourcesAttributes: commonAttrs.javaResourcesAttributes, }, } @@ -2948,19 +2949,6 @@ func javaBinaryHostBp2Build(ctx android.TopDownMutatorContext, m *Binary) { ktAttrs.javaCommonAttributes.Common_srcs = bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, m.properties.Common_srcs)) } - // kt_jvm_library does not support resource_strip_prefix, if this attribute - // is set, than javaResourcesAttributes needs to be set in the - // javaCommonAttributes of the java_binary target - if commonAttrs.javaResourcesAttributes != nil { - if commonAttrs.javaResourcesAttributes.Resource_strip_prefix != nil { - attrs.javaCommonAttributes = &javaCommonAttributes{ - javaResourcesAttributes: commonAttrs.javaResourcesAttributes, - } - } else { - ktAttrs.javaCommonAttributes.javaResourcesAttributes = commonAttrs.javaResourcesAttributes - } - } - ctx.CreateBazelTargetModule(ktProps, android.CommonAttributes{Name: ktName}, ktAttrs) attrs.Runtime_deps.Add(&bazel.LabelAttribute{Value: &bazel.Label{Label: ":" + ktName}}) } -- cgit v1.2.3-59-g8ed1b