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

wanted: io_grpc_grpc_java #353

Closed
alexeagle opened this issue Jan 9, 2023 · 9 comments · Fixed by #1699
Closed

wanted: io_grpc_grpc_java #353

alexeagle opened this issue Jan 9, 2023 · 9 comments · Fixed by #1699
Labels
module wanted Users want a certain module to be available in the BCR, contributions are welcome!

Comments

@alexeagle
Copy link
Contributor

alexeagle commented Jan 9, 2023

Module location

https://github.com/grpc/grpc-java

Link to bzlmod issue in the module's repository

grpc/grpc-java#9559

@alexeagle alexeagle added the module wanted Users want a certain module to be available in the BCR, contributions are welcome! label Jan 9, 2023
@meteorcloudy
Copy link
Member

Do we really need grpc-java as a Bazel module, or should Bazel users just fetch the jar dependencies via rules_jvm_external?

@alexeagle
Copy link
Contributor Author

alexeagle commented Jan 10, 2023

Yes, I think we do, because it has the java_grpc_library rule which relies on the protoc plugin in that repo.

@alexeagle
Copy link
Contributor Author

Another resolution for this is to relocate the java_grpc_library rule to somewhere like rules_java or contrib_rules_jvm - it doesn't seem like maintainers on grpc/grpc-java are excited to continue providing Bazel rules from there, and I think they probably shouldn't be maintaining any. @shs96c will know what to do :)

@meteorcloudy
Copy link
Member

Yes, I would also like to see the Bazel APIs to be moved out of grpc-java if they are not getting well maintained there.

@shs96c
Copy link
Contributor

shs96c commented Jan 11, 2023

GRPC-related things feel like a better fit for one of the (many) grpc providing rulesets.

@alexeagle
Copy link
Contributor Author

Do you have a recommendation of which one? None of them are canonical and last time the SIG touched this in https://bazel-contrib.github.io/SIG-rules-authors/proto-grpc.html we just made a spreadsheet because things were so confusing.

@ejona86
Copy link

ejona86 commented May 25, 2023

it doesn't seem like maintainers on grpc/grpc-java are excited to continue providing Bazel rules from there

I am currently keeping the rules roughly in-sync with those inside Google for Blaze. The story may be different for other languages, but for Java there's been no change to the rule support.

Bzlmod is a different discussion. It looks invasive and a repeated cost as we make releases. So it would take some concerted effort to figure out what the heck is going on and what will be necessary going forward. We accept PRs for new stuff, and maintain what is there already. A PR isn't a sure win, but it generally does make things more clear as to what is going on. I don't see the point of forking if you haven't tried a PR upstream yet.

Do we really need grpc-java as a Bazel module, or should Bazel users just fetch the jar dependencies via rules_jvm_external?

Given you would still need the protoc plugin, which is a native C++ binary, I don't think rules_jvm_external is much of a solution. You would still need the cc_binary from the grpc-java repository.

@plobsing
Copy link
Contributor

Do we really need grpc-java as a Bazel module, or should Bazel users just fetch the jar dependencies via rules_jvm_external?

I've been maintaining a private fork implementing pretty much this concept. I had a completely different reason to do this: the WORKSPACE idioms recommended by grpc-java include overriding certain Maven dependencies with built-from-source versions (IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS). It seems these overrides do not participate in coursier's version resolution but override whatever version does get resolved (even if newer), which can lead to incompatible JARs being used. By plumbing grpc-java version information down into coursier, I was able to convert what had been a recurring, difficult to diagnose, runtime error into a much clearer pinner-execution-time error. Or often, it just selected compatible versions and there were no errors. The information necessary to do proper version resolution is also sufficient to pull the JARs from Maven Central, so there was not much point continuing to build them from source after that.

A few subtle things I learned from this exercise:

  • Public build targets under @io_grpc_grpc_java need to be maintained. Other code expects to reference into it (e.g. grpc-kotlin does). This can be achieved by setting up alias rules.
  • It is likely best to continue adding all grpc-java artifacts to the maven_install call rather than just those strictly necessary at runtime by generated code; grpc-java JARs have exact-version constraints among themselves and coursier is not always smart enough to pick the same version for all of them (e.g. if it wasn't told about certain packages explicitly).

While not a bzlmod module today, I think it would be pretty trivial to convert what I have into one - aside from the ruleset it just references prebuilt assets from Maven Central.

Given you would still need the protoc plugin, which is a native C++ binary, I don't think rules_jvm_external is much of a solution. You would still need the cc_binary from the grpc-java repository.

There are prebuilt versions of the protoc plugin on Maven Central; I believe the Maven protobuf plugin uses them. I've been pulling them in my WORKSPACE file using http_file:

http_file(
    name = "protoc-gen-grpc-java-{platform}".format(platform = platform),
    executable = True,
    sha256 = sha256,
    urls = [
        "https://repo1.maven.org/maven2/io/grpc/protoc-gen-grpc-java/{version}/protoc-gen-grpc-java-{version}-{platform}.exe".format(
            version = version,
            platform = platform,
        ),
    ],
)

Bzlmod is a different discussion. It looks invasive and a repeated cost as we make releases. So it would take some concerted effort to figure out what the heck is going on and what will be necessary going forward. We accept PRs for new stuff, and maintain what is there already. A PR isn't a sure win, but it generally does make things more clear as to what is going on. I don't see the point of forking if you haven't tried a PR upstream yet.

I'm interested in making grpc-java work for bzlmod consumers, and I'd prefer to do that in coordination with upstream. But as I see it, because of issues relating to version resolution mentioned above, having the ruleset live in the same repository as the sourcecode for the JARs is a net negative; an easy protection against aliasing between from-source and Maven-published artifacts is to just not make the sources available in the first place. For that reason, I'd like to see this hosted in a new repo rather than having it be a PR against the existing grpc/grpc-java repo. Could/should that repo live under the gRPC org (and if so what's the protocol to set that up?) or should it live elsewhere?

I am also somewhat concerned about the toil associated with releases; my current workflow is partially manual. It takes a few minutes to do now that I've figured out what needs doing, which is fine for the couple times a year my project updates its version of this dependency, but is a bit much for the couple times a month grpc-java cuts a release. I believe this is a scriptable task, and I've been tinkering on one although I don't have anything working so far.

@keith
Copy link
Member

keith commented Mar 27, 2024

#1699

keith added a commit that referenced this issue Mar 28, 2024
These are in the same PR since they have a circular dependency on each
other

Fixes: #353
Fixes: #1113
aiuto pushed a commit to aiuto/bazel-central-registry that referenced this issue Jun 3, 2024
These are in the same PR since they have a circular dependency on each
other

Fixes: bazelbuild#353
Fixes: bazelbuild#1113
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module wanted Users want a certain module to be available in the BCR, contributions are welcome!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants