Skip to content

Commit e14ae0b

Browse files
Rename maven install back to 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. The PR use a repo mapping trick of `use_repo` to keep BUILD files intact, underlying both `protobuf_maven` and `protobuf_maven_dev` points to the universal `maven` install, while targets in `protobuf_maven_dev` are only available while protobuf is the root module and won't propagate to dependents. PiperOrigin-RevId: 781031722
1 parent 847e7d8 commit e14ae0b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

MODULE.bazel

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,23 +187,24 @@ PROTOBUF_MAVEN_ARTIFACTS = [
187187

188188
protobuf_maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
189189
protobuf_maven.install(
190-
name = "protobuf_maven",
191190
artifacts = PROTOBUF_MAVEN_ARTIFACTS,
192191
lock_file = "//:maven_install.json",
193192
repositories = [
194193
"https://repo1.maven.org/maven2",
195194
"https://repo.maven.apache.org/maven2",
196195
],
197196
)
198-
use_repo(protobuf_maven, "protobuf_maven")
197+
198+
# Use the default "maven" namespace because protobuf java targets are exposed to users
199+
# See https://github.com/protocolbuffers/protobuf/issues/21177
200+
use_repo(protobuf_maven, protobuf_maven = "maven")
199201

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

203205
# Development dependencies
204206
protobuf_maven_dev = use_extension("@rules_jvm_external//:extensions.bzl", "maven", dev_dependency = True)
205207
protobuf_maven_dev.install(
206-
name = "protobuf_maven_dev",
207208
artifacts = PROTOBUF_MAVEN_ARTIFACTS + [
208209
"com.google.caliper:caliper:1.0-beta-3",
209210
"com.google.guava:guava-testlib:32.0.1-jre",
@@ -220,7 +221,7 @@ protobuf_maven_dev.install(
220221
"https://repo.maven.apache.org/maven2",
221222
],
222223
)
223-
use_repo(protobuf_maven_dev, "protobuf_maven_dev")
224+
use_repo(protobuf_maven_dev, protobuf_maven_dev = "maven")
224225

225226
bazel_dep(name = "googletest", version = "1.15.2", dev_dependency = True)
226227
bazel_dep(name = "rules_buf", version = "0.3.0", dev_dependency = True)

0 commit comments

Comments
 (0)