Skip to content

Commit 1999135

Browse files
Rename maven install back to maven in MODULE.bazel
Fixes #21177 This PR essentially reverts #18641, which claimed > Since protobuf is not contributing to user's JARs This is not true since targets like `@com_google_protobuf//:protobuf_java` are meant to be consumed by other projects, therefore protobuf should not use a private maven install namespace. Otherwise, it leads to duplicated maven jars and classpath conflicts. See #21177 and bazel-contrib/rules_jvm_external#916 (comment) The original warning message caused by multiple modules contributing to `maven` can be suppressed with bazel-contrib/rules_jvm_external#1393, which will be available in rules_jvm_external 6.8. Closes #22544 PiperOrigin-RevId: 782032198
1 parent 64a76e6 commit 1999135

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed

MODULE.bazel

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ crate.spec(
174174
crate.from_specs()
175175
use_repo(crate, crate_index = "crates")
176176

177+
# Keep this list minimal; these dependencies will be part of the common `maven` install and could affect end-user projects.
177178
PROTOBUF_MAVEN_ARTIFACTS = [
178179
"com.google.code.findbugs:jsr305:3.0.2",
179180
"com.google.code.gson:gson:2.8.9",
@@ -182,17 +183,19 @@ PROTOBUF_MAVEN_ARTIFACTS = [
182183
"com.google.guava:guava:32.0.1-jre",
183184
]
184185

185-
protobuf_maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
186-
protobuf_maven.install(
187-
name = "protobuf_maven",
186+
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
187+
maven.install(
188188
artifacts = PROTOBUF_MAVEN_ARTIFACTS,
189189
lock_file = "//:maven_install.json",
190190
repositories = [
191191
"https://repo1.maven.org/maven2",
192192
"https://repo.maven.apache.org/maven2",
193193
],
194194
)
195-
use_repo(protobuf_maven, "protobuf_maven")
195+
196+
# Use the default "maven" namespace because protobuf java targets are exposed to users
197+
# See https://github.com/protocolbuffers/protobuf/issues/21177
198+
use_repo(maven, "maven")
196199

197200
# Temporarily pin transitive dependency for https://github.com/bazelbuild/bazel/issues/24426
198201
bazel_dep(name = "re2", version = "2024-07-02.bcr.1")

WORKSPACE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ rules_jvm_external_setup()
6565
load("@rules_jvm_external//:defs.bzl", "maven_install")
6666

6767
maven_install(
68-
name = "protobuf_maven",
68+
name = "maven",
6969
artifacts = PROTOBUF_MAVEN_ARTIFACTS,
7070
# For updating instructions, see:
7171
# https://github.com/bazelbuild/rules_jvm_external#updating-maven_installjson
@@ -76,7 +76,7 @@ maven_install(
7676
],
7777
)
7878

79-
load("@protobuf_maven//:defs.bzl", "pinned_maven_install")
79+
load("@maven//:defs.bzl", "pinned_maven_install")
8080

8181
pinned_maven_install()
8282

examples/WORKSPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ rules_jvm_external_setup()
7676
load("@rules_jvm_external//:defs.bzl", "maven_install")
7777

7878
maven_install(
79-
name = "protobuf_maven",
79+
name = "maven",
8080
artifacts = PROTOBUF_MAVEN_ARTIFACTS,
8181
repositories = [
8282
"https://repo1.maven.org/maven2",

java/util/BUILD.bazel

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ java_library(
1414
visibility = ["//visibility:public"],
1515
deps = [
1616
"//java/core",
17-
"@protobuf_maven//:com_google_code_findbugs_jsr305",
18-
"@protobuf_maven//:com_google_code_gson_gson",
19-
"@protobuf_maven//:com_google_errorprone_error_prone_annotations",
20-
"@protobuf_maven//:com_google_guava_guava",
21-
"@protobuf_maven//:com_google_j2objc_j2objc_annotations",
17+
"@maven//:com_google_code_findbugs_jsr305",
18+
"@maven//:com_google_code_gson_gson",
19+
"@maven//:com_google_errorprone_error_prone_annotations",
20+
"@maven//:com_google_guava_guava",
21+
"@maven//:com_google_j2objc_j2objc_annotations",
2222
],
2323
)
2424

@@ -34,11 +34,11 @@ protobuf_versioned_java_library(
3434
visibility = ["//visibility:public"],
3535
deps = [
3636
"//java/core",
37-
"@protobuf_maven//:com_google_code_findbugs_jsr305",
38-
"@protobuf_maven//:com_google_code_gson_gson",
39-
"@protobuf_maven//:com_google_errorprone_error_prone_annotations",
40-
"@protobuf_maven//:com_google_guava_guava",
41-
"@protobuf_maven//:com_google_j2objc_j2objc_annotations",
37+
"@maven//:com_google_code_findbugs_jsr305",
38+
"@maven//:com_google_code_gson_gson",
39+
"@maven//:com_google_errorprone_error_prone_annotations",
40+
"@maven//:com_google_guava_guava",
41+
"@maven//:com_google_j2objc_j2objc_annotations",
4242
],
4343
)
4444

0 commit comments

Comments
 (0)