diff --git a/bp2build/java_library_conversion_test.go b/bp2build/java_library_conversion_test.go index e37fa627a..84c664e24 100644 --- a/bp2build/java_library_conversion_test.go +++ b/bp2build/java_library_conversion_test.go @@ -685,6 +685,7 @@ func TestJavaLibraryKotlinSrcs(t *testing.T) { "c.kt", ]`, }), + MakeNeverlinkDuplicateTarget("kt_jvm_library", "java-lib-1"), }, }) } @@ -707,6 +708,7 @@ func TestJavaLibraryKotlinCommonSrcs(t *testing.T) { ]`, "common_srcs": `["c.kt"]`, }), + MakeNeverlinkDuplicateTarget("kt_jvm_library", "java-lib-1"), }, }) } diff --git a/java/java.go b/java/java.go index e83678ed1..946a1df4f 100644 --- a/java/java.go +++ b/java/java.go @@ -2764,14 +2764,6 @@ func javaLibraryBp2Build(ctx android.TopDownMutatorContext, m *Library) { Rule_class: "java_library", Bzl_load_location: "//build/bazel/rules/java:library.bzl", } - - ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name}, attrs) - neverlinkProp := true - neverLinkAttrs := &javaLibraryAttributes{ - Exports: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + name}), - Neverlink: bazel.BoolAttribute{Value: &neverlinkProp}, - } - ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name + "-neverlink"}, neverLinkAttrs) } else { attrs.Common_srcs = bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, m.properties.Common_srcs)) @@ -2779,10 +2771,16 @@ func javaLibraryBp2Build(ctx android.TopDownMutatorContext, m *Library) { Rule_class: "kt_jvm_library", Bzl_load_location: "@rules_kotlin//kotlin:jvm_library.bzl", } - // TODO (b/244210934): create neverlink-duplicate target once kt_jvm_library supports neverlink attribute - ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name}, attrs) } + ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name}, attrs) + neverlinkProp := true + neverLinkAttrs := &javaLibraryAttributes{ + Exports: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + name}), + Neverlink: bazel.BoolAttribute{Value: &neverlinkProp}, + } + ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name + "-neverlink"}, neverLinkAttrs) + } type javaBinaryHostAttributes struct {