summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
author Liz Kammer <eakammer@google.com> 2023-10-11 15:24:24 -0400
committer Liz Kammer <eakammer@google.com> 2023-10-17 09:10:13 -0400
commit4e00b0929b3806667be974b0fd1efab06cca063e (patch)
tree2d8707738472105e7e1a6f348b98d586be8ed18f /java/java.go
parentba5f32a2f9f48ebc1399ece9ee77dced868d78bc (diff)
Don't use java_library for java_import neverlink
Restricting use of sdk_version = "none" to only the rule types that will correctly handled sdk_version = "none" by also handling system_module attr Test: CI && go tests Change-Id: Ifa1c60ba8f5e3fcb28986cc84cdfaedcbd2d2957
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go43
1 files changed, 28 insertions, 15 deletions
diff --git a/java/java.go b/java/java.go
index 990a084f7..0594a8b93 100644
--- a/java/java.go
+++ b/java/java.go
@@ -3403,9 +3403,14 @@ func createLibraryTarget(ctx android.Bp2buildMutatorContext, libInfo libraryCrea
return libName
}
-type bazelJavaImportAttributes struct {
- Jars bazel.LabelListAttribute
- Exports bazel.LabelListAttribute
+type importAttributes struct {
+ Jars bazel.LabelListAttribute
+ Exports bazel.LabelListAttribute
+ Neverlink *bool
+}
+
+type filegroupAttrs struct {
+ Srcs bazel.LabelListAttribute
}
// java_import bp2Build converter.
@@ -3421,28 +3426,36 @@ func (i *Import) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
}
}
- attrs := &bazelJavaImportAttributes{
- Jars: jars,
+ name := android.RemoveOptionalPrebuiltPrefix(i.Name())
+ filegroupTargetName := name + "-jars"
+
+ ctx.CreateBazelTargetModule(
+ bazel.BazelTargetModuleProperties{
+ Rule_class: "filegroup",
+ Bzl_load_location: "//build/bazel/rules:filegroup.bzl",
+ },
+ android.CommonAttributes{Name: filegroupTargetName},
+ &filegroupAttrs{
+ Srcs: jars,
+ },
+ )
+
+ attrs := &importAttributes{
+ Jars: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + filegroupTargetName}),
}
props := bazel.BazelTargetModuleProperties{
Rule_class: "java_import",
Bzl_load_location: "//build/bazel/rules/java:import.bzl",
}
- name := android.RemoveOptionalPrebuiltPrefix(i.Name())
-
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name}, attrs)
- neverlink := true
- neverlinkAttrs := &javaLibraryAttributes{
- Neverlink: bazel.BoolAttribute{Value: &neverlink},
- Exports: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + name}),
- javaCommonAttributes: &javaCommonAttributes{
- Sdk_version: bazel.StringAttribute{Value: proptools.StringPtr("none")},
- },
+ neverlinkAttrs := &importAttributes{
+ Jars: attrs.Jars,
+ Neverlink: proptools.BoolPtr(true),
}
ctx.CreateBazelTargetModule(
- javaLibraryBazelTargetModuleProperties(),
+ props,
android.CommonAttributes{Name: name + "-neverlink"},
neverlinkAttrs)
}