-
Notifications
You must be signed in to change notification settings - Fork 15.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rename maven to protobuf_maven in MODULE.bazel #18641
Conversation
The default name for the rules_jvm_external.maven rule is "maven". When not set, it defaults to "maven". For root modules also using rules_jvm_external, the name clash causes a warning: ``` DEBUG: $TMP/external/rules_jvm_external~/private/extensions/maven.bzl:154:14: The maven repository 'maven' is used in two different bazel modules, originally in '<my_workspace>' and now in 'protobuf' ``` Summarizing @shs96c in [1]: > The common maven repo name allows rulesets to contribute to the user's JARs. > However, this implies that maven is for the end user, not for transitive > dependencies. If a ruleset needs private dependencies, it should use a custom > namespace rather than the maven namespace. Since protobuf is not contributing to user's JARs, we'll use a custom namespace. There's precedent for using a custom namespace for library modules: - rules_jvm_external uses `rules_jvm_external_deps` instead of `maven`. - rules_kotlin uses `kotlin_rules_maven` instead of `maven`. [1]: bazel-contrib/rules_jvm_external#916 (comment) Fixes protocolbuffers#16839.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix!
@@ -73,7 +73,7 @@ maven_install( | |||
], | |||
) | |||
|
|||
load("@maven//:defs.bzl", "pinned_maven_install") | |||
load("@protobuf_maven//:defs.bzl", "pinned_maven_install") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change correct? In the error logs for the failing tests we see:
ERROR: Failed to load Starlark extension '@@protobuf_maven//:defs.bzl'.
Cycle in the workspace file detected. This indicates that a repository is used prior to being defined.
The following chain of repository dependencies lead to the missing definition.
- @@protobuf_maven
This could either mean you have to add the '@@protobuf_maven' repository with a statement like `http_archive` in your WORKSPACE file (note that transitive dependencies are not added automatically), or move an existing definition earlier in your WORKSPACE file.
ERROR: Error computing the main repository mapping: cycles detected during computation of main repo mapping
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the problem was I forgot to add the name = "protobuf_maven"
in the WORKSPACE. I only did it in MODULE.bazel for the first commit.
FYI: this looks broken for protobuf-util, as that does contribute to user's JARs. See my comment on a PR to do something similar in gRPC: grpc/grpc-java#11614 (comment) |
Because protobuf/java/core/BUILD.bazel Line 334 in 5c5d407
And if you use Bazel-built "core" then you need Bazel-built "util". |
@ejona86 - can you open a new issue for the protobuf-util problem? |
The default name for the rules_jvm_external.maven rule is "maven". When not set, it defaults to "maven". For root modules also using rules_jvm_external, the name clash causes a warning: ``` DEBUG: $TMP/external/rules_jvm_external~/private/extensions/maven.bzl:154:14: The maven repository 'maven' is used in two different bazel modules, originally in '<my_workspace>' and now in 'protobuf' ``` Summarizing @shs96c in [1]: > The common maven repo name allows rulesets to contribute to the user's JARs. > However, this implies that maven is for the end user, not for transitive > dependencies. If a ruleset needs private dependencies, it should use a custom > namespace rather than the maven namespace. Since protobuf is not contributing to user's JARs, we'll use a custom namespace. There's precedent for using a custom namespace for library modules: - rules_jvm_external uses `rules_jvm_external_deps` instead of `maven`. - rules_kotlin uses `kotlin_rules_maven` instead of `maven`. [1]: bazel-contrib/rules_jvm_external#916 (comment) Fixes #16839. Closes #18641 COPYBARA_INTEGRATE_REVIEW=#18641 from jschaf:joe/protobuf-maven bd2c62f PiperOrigin-RevId: 684625084
The default name for the rules_jvm_external.maven rule is "maven". When not set, it defaults to "maven". For root modules also using rules_jvm_external, the name clash causes a warning: ``` DEBUG: $TMP/external/rules_jvm_external~/private/extensions/maven.bzl:154:14: The maven repository 'maven' is used in two different bazel modules, originally in '<my_workspace>' and now in 'protobuf' ``` Summarizing @shs96c in [1]: > The common maven repo name allows rulesets to contribute to the user's JARs. > However, this implies that maven is for the end user, not for transitive > dependencies. If a ruleset needs private dependencies, it should use a custom > namespace rather than the maven namespace. Since protobuf is not contributing to user's JARs, we'll use a custom namespace. There's precedent for using a custom namespace for library modules: - rules_jvm_external uses `rules_jvm_external_deps` instead of `maven`. - rules_kotlin uses `kotlin_rules_maven` instead of `maven`. [1]: bazel-contrib/rules_jvm_external#916 (comment) Fixes #16839. Closes #18641 COPYBARA_INTEGRATE_REVIEW=#18641 from jschaf:joe/protobuf-maven bd2c62f PiperOrigin-RevId: 684625084 Co-authored-by: Joe Schafer <[email protected]>
The default name for the rules_jvm_external.maven rule is "maven". When not set, it defaults to "maven". For root modules also using rules_jvm_external, the name clash causes a warning:
Summarizing @shs96c in 1:
Since protobuf is not contributing to user's JARs, we'll use a custom namespace. There's precedent for using a custom namespace for library modules:
rules_jvm_external_deps
instead ofmaven
.kotlin_rules_maven
instead ofmaven
.Fixes #16839.