api: add proto options for java#5369
Conversation
Signed-off-by: Penn (Dapeng) Zhang <zdapeng@google.com>
dad1c94 to
1e82546
Compare
|
@snowp Since you have most of the recent commits in java-control-plane, can you review this? |
snowp
left a comment
There was a problem hiding this comment.
Adding these options seems fine to me. Would it be possible to add something to CI that ensures that we do this for all future protos so that we keep this consistent? Maybe just a simple script we can run in the bazel.api CI task?
Signed-off-by: Penn (Dapeng) Zhang <zdapeng@google.com>
cdcc609 to
b74551d
Compare
ggreenway
left a comment
There was a problem hiding this comment.
Also, please don't force-push to the PR branch; it makes it more difficult to review the incremental diffs. We'll squash-merge the PR when it's ready, so it's easier for the maintainers if you leave all the intermediate commits. Thanks!
|
@ggreenway Thank you for your suggestions. The force push was because I forgot |
Ok, that makes sense. Carry on :) |
This reverts commit b74551d. Signed-off-by: Penn (Dapeng) Zhang <zdapeng@google.com>
Signed-off-by: Penn (Dapeng) Zhang <zdapeng@google.com>
Signed-off-by: Penn (Dapeng) Zhang <zdapeng@google.com>
|
You will need to merge master to pick up a fix for mac build failure |
tools/check_format.py
Outdated
| java_package_correct = True | ||
| if java_multiple_files and java_package_correct: | ||
| return [] | ||
| return ["Java proto options are not set correctly for file: %s" % file_path] |
There was a problem hiding this comment.
Can we output what options are missing? Would save people from having to grep around to figure out what's wrong
There was a problem hiding this comment.
Added more detailed error messages.
| syntax = "proto3"; | ||
|
|
||
| package envoy.api.v2; | ||
| option java_package = "io.envoyproxy.envoy.api.v2"; |
There was a problem hiding this comment.
Out of curiosity, is there no way to have the Java protoc plugin take the organizational package prefix (in this case 'io.envoyproxy) as a CLI arguement and prefix it automatically? It seems this would be a common case thing to want to do.
|
This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
…-java-options Signed-off-by: Penn (Dapeng) Zhang <zdapeng@google.com>
Signed-off-by: Penn (Dapeng) Zhang <zdapeng@google.com>
Signed-off-by: Penn (Dapeng) Zhang <zdapeng@google.com>
snowp
left a comment
There was a problem hiding this comment.
Looks good to me, thanks!
If you have a chance to update java-control-plane when this lands that'd be awesome, if not no worries
|
Thank you all for the review. @snowp, I sent out a PR envoyproxy/java-control-plane#86 to update java-control-plane.
|
* api: add proto options for java * add ci for checking proto options Signed-off-by: Penn (Dapeng) Zhang <zdapeng@google.com> Signed-off-by: Fred Douglas <fredlas@google.com>
Description:
Without the proto option
java_package, the proto java codegen will generate classes with a "default package". Take thecds.protofile for example, in envoyproxy/java-control-plane, it will generate a java classenvoy.api.v2.Cds.Cluster. But java packages normally starts with a domain name.io.envoyproxy.envoy.api.v2.Cds.Clusterwould be better for java convention. Another proto optionjava_multiple_files = trueis also recommended for most cases.The PR is generated by running:
Risk Level: Medium
Note that e.g. envoyproxy/java-control-plane will have to do a refactoring when they sync the proto files next time.
Testing: N/A
Docs Changes: N/A
Release Notes: added proto options for java