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

Bazel: support @generated=omit #11226

Closed
ah-quant opened this issue May 21, 2024 · 3 comments
Closed

Bazel: support @generated=omit #11226

ah-quant opened this issue May 21, 2024 · 3 comments

Comments

@ah-quant
Copy link

ah-quant commented May 21, 2024

Is your feature request related to a problem?

There is currently no simple way to use the (wonderful) new 1.64.0 feature @generated=omit from Bazel. Which leaves Bazel users with a superfluous dependency for a single annotation.

It might be possible to do so with a new toolchain, but that's a lot of effort for a minor feature. If that doesn't work either, it's probably impossible. This might also be related to #11097

Describe the solution you'd like

Either set it to omit by default or add an option to change it.

https://github.com/grpc/grpc-java/blob/v1.64.0/java_grpc_library.bzl#L95 looks like the right place; args.add("--rpc-plugin_opt=@generated={0}".format(<???>)) behind a conditional (only if non-default) should do the trick - with a new attribute in the rules below.

The ..._opt flag to set the CodeGeneratorRequest.parameter for a plugin is not well documented, but is referenced e.g. here: protocolbuffers/protobuf#4759 (comment) (EDIT: a better reference would be https://github.com/protocolbuffers/protobuf/blob/v26.1/src/google/protobuf/compiler/command_line_interface.h#L107-L175)

It can occur more than once. It might even be worth it to also use this instead of the lite/non-lite toolchains.

Describe alternatives you've considered

I tried a .bazelrc entry with build --protocopt=--rpc-plugin_opt=@generated=omit - but that failed. The descriptors are created before the plugin is called, the option is unknown at that point and the command fails.

Additional context

@ejona86
Copy link
Member

ejona86 commented May 21, 2024

I think this is mostly infeasible/not worth the effort. Even without the @Generated annotation, your dependencies wouldn't change and you'd still depend on the old j2ee stuff.

Yes, with specific toolchain plumbing that could maybe be managed, but that's a lot of effort for this neverlink=1 dependency. It'd be much easier for someone to just pick up #9179.

@ejona86 ejona86 closed this as completed May 21, 2024
@Hc747
Copy link

Hc747 commented May 22, 2024

Picked up #9179 for you here #11215 :)

@ejona86
Copy link
Member

ejona86 commented May 22, 2024

@Hc747, please actually read the beginning of #9179. Its title is "Replace javax.annotation.Generated with custom gRPC annotation," which is quite different than that PR.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants