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

Java generated code for plugin.proto not available in a protobuf artifact #182

Closed
jhump opened this issue Jan 28, 2015 · 6 comments
Closed

Comments

@jhump
Copy link
Contributor

jhump commented Jan 28, 2015

See original issue from old googlecode issue tracker:
https://code.google.com/p/protobuf/issues/detail?id=185

Related: it would be nice to get this set of helper classes in, too:
https://codereview.appspot.com/912042
They may not make sense in the protobuf runtime JAR, but maybe in a separate artifact that also includes generated Java code for plugin.proto?

@jhump
Copy link
Contributor Author

jhump commented Jan 28, 2015

This was still true as of the latest released version: 2.6.1

@xfxyjwf
Copy link
Contributor

xfxyjwf commented Jan 29, 2015

In C++, generated code of plugin.proto is included in libprotoc which is used by whoever need to write a compiler plugin. In Java though, there isn't an equivalent of C++'s libprotoc and it's not recommended to write the plugin in Java as well. For this reason I think we'll not provide any Java artifact for plugin.proto.

@JasonRosenberg
Copy link

Hi Feng,

There are many users of java plugins for protoc. There's also a maven plugin that launches them:

http://sergei-ivanov.github.io/maven-protoc-plugin/examples/protoc-plugin.html

This is the standard maven plugin for compiling protos with maven, and it supports java based protoc plugins.

However, any java plugin has to manually compile the plugin.proto into java, and package that with the plugin code (which is not as nice has having it be an artifact that is generated from the standard protobuf distribution).

Previous commits to the plugin.proto support to support java package naming have been committed, here:

2273ee4#diff-3

All that's remaining is to have a compiled version of this proto appear either in the java runtime jar, or in a separately generated 'plugin support' jar. The easiest path would be to just add it to the java runtime (in the same way that several other compiled protos are included, e.g.):

https://github.com/google/protobuf/blob/master/java/pom.xml#L84

Alternately, a nice helper library was also developed, which could be nice to include in 'plugin support' jar (linked to by @jhump above).

@sergei-ivanov
Copy link
Contributor

@xfxyjwf Yes, it would be nice if all .proto files (plugin.proto, descriptor.proto and others, excluding the unit test ones) from https://github.com/google/protobuf/tree/master/src/google/protobuf were compiled into java and bundled into a jar file together with the generated java classes. This would have allowed us to include them directly as a dependency, instead of copying the .proto files into the project. Writing a plugin in Java is arguably much easier than in C++, the relevant expertise is easier to find, and the Java toolchain is much easier to set up. We had our own custom plugin written in Java, which generated low-allocation versions of protobuf messages, and that worked really well for us. Unfortunately, it was never made public, but that is a different story.

EDIT: if implemented, this obviously needs to be a separate artifact, not part of protobuf-java-x.x.x.jar.

@xfxyjwf
Copy link
Contributor

xfxyjwf commented Jan 20, 2016

FYI. The latest protobuf-java artifacts now include the generated code of plugin.proto (and a bunch of others).

@xfxyjwf xfxyjwf closed this as completed Jan 20, 2016
@sergei-ivanov
Copy link
Contributor

A little note of appreciation. I've just picked the latest protobuf beta up, and I could finally delete generated classes for PluginProtos and DescriptorProtos from my git repo. Everything works a treat, and writing plugins for protoc in Java has just become much simpler.
Thank you very much for implementing this.

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

4 participants