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

Package name alteration #389

Open
andrewparmet opened this issue May 14, 2023 · 1 comment
Open

Package name alteration #389

andrewparmet opened this issue May 14, 2023 · 1 comment
Assignees

Comments

@andrewparmet
Copy link
Contributor

andrewparmet commented May 14, 2023

I write a protobuf compiler (https://github.com/open-toast/protokt) for the JVM that I want to "play nicely" with grpc-kotlin. Right now I accomplish this by choosing the package of generated classes to match the package that would be chosen by protobuf-java. The grpc-kotlin generator is agnostic as to the implementation of its request and response types, so by generating service descriptors and method descriptors with the right package names, class names, and function names I can "plug and play" into the stubs generated by grpc-kotlin.

This comes with an unfortunate side effect: protokt users cannot also have the protobuf-java generated code on their classpaths due to the inevitable classpath collisions. I'd like to figure out a way to achieve both goals - play nicely with grpc-kotlin and with protobuf-java.

The most promising way I know to alleviate classpath collisions is to mangle package names in a way unique to my generator (e.g. by adding a prefix like protokt. to every package), but then grpc-kotlin won't know how to generate code with the right packages to match.

Another option is to use a file option kotlin_package to specify the Kotlin package of code in a file and teach grpc-kotlin how to use it, but then users won't be able to use third-party types as their request or response types since they won't have that option specified. Maybe that's not such a bad convention, but ideally protokt doesn't dictate it. (As an aside, they already can't use classes from com.google.protobuf for this reason - we have to mangle our versions of those in order to use the protobuf-java runtime.)

Is there an existing mechanism (or could there be one) to handle this sort of use case?

related: open-toast/protokt#173 open-toast/protokt#169

@andrewparmet
Copy link
Contributor Author

Rather than supporting a new option, an alternative would be to use this code generator as a library and modify our input protos. This would be similar to running it as a plugin but we don't need a self-contained executable.

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

No branches or pull requests

2 participants