-
Notifications
You must be signed in to change notification settings - Fork 37
protoc extensions supported. #27
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
protoc extensions supported. #27
Conversation
|
Thanks for the contribution! Before we can merge this, we need @noel-yap to sign the Salesforce Contributor License Agreement. |
Codecov Report
@@ Coverage Diff @@
## master #27 +/- ##
============================================
- Coverage 58.14% 57.11% -1.04%
Complexity 97 97
============================================
Files 19 19
Lines 442 450 +8
Branches 33 34 +1
============================================
Hits 257 257
- Misses 177 185 +8
Partials 8 8
Continue to review full report at Codecov.
|
|
Thanks for the PR! Could you elaborate on what this does? |
rmichela
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Can you also add a section to the JProtoc README.md with an example of how to author an generator that uses extensions?
| generate(generators, Collections.emptyList()); | ||
| } | ||
|
|
||
| public static void generate( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs JavaDoc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| Preconditions.checkArgument(!generators.isEmpty(), "generators.isEmpty()"); | ||
| Preconditions.checkNotNull(extensions, "extensions"); | ||
|
|
||
| ExtensionRegistry extensionRegistry = ExtensionRegistry.newInstance(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment explaining what the extensionRegistry does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| string name = 1; | ||
| } | ||
| ``` | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I have to run the protobuf generator as part of the build process for my protobuf plugin? Do I need to add this to my plugin project's POM?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with Maven but I don't see any reason anything in the build would have to change. All the processing is done at protoc run-time when protoc calls the protoc plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm not understanding correctly. Where does the type com.example.proto.options.ServerOptionsProto.server come from in the example below? Perhaps you could add an elaborated example in jprotoc-test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that's generated by protoc. Those not creating custom options don't need to run protoc to generate the related Java code for the option. I'm assuming those creating custom options would know how to run protoc to do that. I can add a blurb about running protoc if you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see...My JProtoc Protobuf generator project would itself contain Protobuf generated code (it's proto all the way down!). A line to say "Run the Protoc generator on the Extension proto" should suffice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
I'm not understanding the output of the code coverage report. Some lines (eg |
|
Ignore the CodeCov report. I'm still trying to get it working right. 😉 |
…-java-contrib into feature/support-extensions
…-exec-maven-plugin-3.1.0 build(deps): bump exec-maven-plugin from 1.6.0 to 3.1.0
Custom protoc options (https://developers.google.com/protocol-buffers/docs/proto3#custom_options) are implemented via extensions (https://developers.google.com/protocol-buffers/docs/reference/java-generated#extension). If a custom option is to be processed by a protoc plugin, the plugin code must register the extension. For example (from the docs):