Skip to content
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

Maven dependencies not exposed to Bazel users #9132

Closed
Kernald opened this issue Oct 21, 2021 · 2 comments
Closed

Maven dependencies not exposed to Bazel users #9132

Kernald opened this issue Oct 21, 2021 · 2 comments
Assignees
Labels

Comments

@Kernald
Copy link
Contributor

Kernald commented Oct 21, 2021

What version of protobuf and what language are you using?
Version: v3.19.0
Language: C++/Java/Kotlin

What operating system (Linux, Windows, ...) and version?
macOS 11.6

What runtime / compiler are you using (e.g., python version or gcc version)
LLVM 12.0.0, Kotlinc 1.5.21

What did you do?
Steps to reproduce the behavior:

  1. Depend on Protobuf 3.19.0 through Bazel
  2. Try to build something depending on @com_google_protobuf//java/util:util

What did you expect to see
The build should succeed

What did you see instead?

ERROR: /private/var/tmp/_bazel_kernald/dc8fa02be43b6315d36f6bf2bf056429/external/com_google_protobuf/java/util/BUILD:7:13: no such target '//external:j2objc_annotations': target 'j2objc_annotations' not declared in package 'external' defined by /Users/kernald/dev/monos/WORKSPACE and referenced by '@com_google_protobuf//java/util:util'
ERROR: /private/var/tmp/_bazel_kernald/dc8fa02be43b6315d36f6bf2bf056429/external/com_google_protobuf/java/util/BUILD:7:13: no such target '//external:jsr305': target 'jsr305' not declared in package 'external' defined by /Users/kernald/dev/monos/WORKSPACE and referenced by '@com_google_protobuf//java/util:util'

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment
gRPC-Java and gRPC-Kotlin (at least) address this problem by exposing the list of dependencies they need: https://github.com/grpc/grpc-java/blob/25022f6846ec1fdd8003789cba32d4ca981c3171/repositories.bzl

@elharo elharo added the bazel label Oct 21, 2021
@acozzette acozzette self-assigned this Oct 27, 2021
acozzette added a commit to acozzette/protobuf that referenced this issue Oct 27, 2021
This commit removes the use of bind() since that function goes against
Bazel best practices:
https://docs.bazel.build/versions/main/external.html#repository-rules-1
The bind() function basically maps a dependency into //external:, but
there is no good reason to do this. By mapping dependencies into
//external: and relying on this in our own BUILD files, we're forcing
projects that depend on us to do the same.

This change also moves our list of required Maven artifacts into
protobuf_deps.bzl. This way, projects that depend on us can refer to
this list when they invoke maven_install() and automatically pull in all
the necesary dependencies.

This fixes protocolbuffers#9132.
acozzette added a commit to acozzette/protobuf that referenced this issue Oct 27, 2021
This commit removes the use of bind() since that function goes against
Bazel best practices:
https://docs.bazel.build/versions/main/external.html#repository-rules-1
The bind() function basically maps a dependency into //external, but
there is no good reason to do this. By mapping dependencies into
//external and relying on this in our own BUILD files, we're forcing
projects that depend on us to do the same. The one bind() call that I
did leave in place was //:python_headers. This one seems to be doing
something complicated I don't fully understand, and I don't want to risk
breaking it.

This change also moves our list of required Maven artifacts into a
constant in protobuf_deps.bzl. This way, projects that depend on us can
refer to this list when they invoke maven_install() and automatically
pull in all the necesary dependencies.

This fixes protocolbuffers#9132.
acozzette added a commit that referenced this issue Oct 28, 2021
This commit removes the use of bind() since that function goes against
Bazel best practices:
https://docs.bazel.build/versions/main/external.html#repository-rules-1
The bind() function basically maps a dependency into //external, but
there is no good reason to do this. By mapping dependencies into
//external and relying on this in our own BUILD files, we're forcing
projects that depend on us to do the same. The one bind() call that I
did leave in place was //:python_headers. This one seems to be doing
something complicated I don't fully understand, and I don't want to risk
breaking it.

This change also moves our list of required Maven artifacts into a
constant in protobuf_deps.bzl. This way, projects that depend on us can
refer to this list when they invoke maven_install() and automatically
pull in all the necesary dependencies.

This fixes #9132.
@acozzette
Copy link
Member

This should be fixed now with #9165, which I plan to release in 3.19.1. In protobuf_deps.bzl we now define a constant PROTOBUF_MAVEN_ARTIFACTS that you can use with maven_install() in your WORKSPACE file to make sure all protobuf's Java dependencies are available.

@Kernald
Copy link
Contributor Author

Kernald commented Oct 29, 2021

Just confirming that it's fixed for me in 3.19.1 with the new PROTOBUF_MAVEN_ARTIFACTS. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants