Create helper function for BazelTargetModuleProperties in java/android
Prevents inconsistent load locations from being added for java_library,
android_library, kt_jvm_library targets that are generated in multiple
places.
Change-Id: I66ae5af137d7dff3f6fa6660dee539cf9ab22b9e
Test: go test ./bp2build
diff --git a/java/aar.go b/java/aar.go
index 7c45efe..4bc5465 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -1067,10 +1067,7 @@
neverlink := true
ctx.CreateBazelTargetModule(
- bazel.BazelTargetModuleProperties{
- Rule_class: "android_library",
- Bzl_load_location: "//build/bazel/rules/android:rules.bzl",
- },
+ AndroidLibraryBazelTargetModuleProperties(),
android.CommonAttributes{Name: name + "-neverlink"},
&bazelAndroidLibrary{
javaLibraryAttributes: &javaLibraryAttributes{
@@ -1081,6 +1078,12 @@
)
}
+func AndroidLibraryBazelTargetModuleProperties() bazel.BazelTargetModuleProperties {
+ return bazel.BazelTargetModuleProperties{
+ Rule_class: "android_library",
+ Bzl_load_location: "//build/bazel/rules/android:rules.bzl",
+ }
+}
func (a *AndroidLibrary) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
commonAttrs, bp2buildInfo := a.convertLibraryAttrsBp2Build(ctx)
@@ -1093,10 +1096,7 @@
ctx.ModuleErrorf("Module has direct dependencies but no sources. Bazel will not allow this.")
}
name := a.Name()
- props := bazel.BazelTargetModuleProperties{
- Rule_class: "android_library",
- Bzl_load_location: "//build/bazel/rules/android:rules.bzl",
- }
+ props := AndroidLibraryBazelTargetModuleProperties()
ctx.CreateBazelTargetModule(
props,