Import .proto file and generated Java classes from JAR

538 views
Skip to first unread message

Stik kos

unread,
Mar 10, 2014, 12:22:03 PM3/10/14
to prot...@googlegroups.com
Hello,

We have defined a bunch of common messages (like Country, Currency, Money, ...) and packaged them in a JAR together with the generated (and compiled) JAVA classes. We would then like to have multiple projects include this JAR as a dependency. 
Is it possible to import a .proto file directly from a JAR? 
And is it possible to not generate JAVA files for these common messages but use the once in the common JAR in stead?

Thanks,
Stik

Christopher Head

unread,
Mar 14, 2014, 2:23:17 AM3/14/14
to Stik kos, prot...@googlegroups.com
You shouldn’t need the .proto files at all in order to *use* the
messages from other applications; that’s what the generated language
source files are for. Java being what it is, you should just be able to
use the .class files from your .jar without including either the .proto
or .java files at all, just like you would use .class files in any
other .jar-based library you use in your system: arrange for the .jar
to be in your classpath, like you would do with any other library .jar,
and then consume the appropriate classes in your own code, like you
would with any other library.
--
Christopher Head
signature.asc
Reply all
Reply to author
Forward
0 new messages