I\'m using Google Protocol Buffers to generate some Java classes for my project. Using Maven 2 and its \"antrun\" plugin, these classes are freshly generated before compile,
To generate Java source files from .proto files use Protocol Buffers Plugin which works out-of-the-box in eclipse Oxygen.
Basic usage (see here for detailed description):
make sure that native protoc compiler is installed on your system
update your pom.xml file:
make sure you use at least Java 6 (Java 7+ is recommended)
add plugin invocation
add the corresponding dependency for com.google.protobuf:protobuf-java
put your .proto files inside project's src/main/proto directory
update the project (via Maven -> Update project...)
Example pom.xml:
...
org.apache.maven.plugins
maven-compiler-plugin
3.7.0
1.6
1.6
org.xolstice.maven.plugins
protobuf-maven-plugin
0.5.1
/usr/local/bin/protoc
compile
test-compile
...
com.google.protobuf
protobuf-java
3.5.1
...
...
Some additional notes:
if protoc executable is in the PATH the protocExecutable configuration entry can be omitted
test-only protobuf message definitions can be put into project's src/test/proto directory
I recommend installing Protocol Buffer Descriptor Editor (marketplace link)
Good luck!