For my team, I\'d like to configure maven/eclipse build to automatically generate Java code from *.proto files (in a project that uses gRPC). Currently one need
Instead of using org.xolstice.maven.plugins:protobuf-maven-plugin my team has used com.github.os72:protoc-jar-maven-plugin to generate the message classes. I believe they are the same since under the hood they all seem to be using the tools from Google.
I am not using any m2e connectors for this plugin (Edit: protoc-jar-maven-plugin's m2e connector is bundled with it so no extra installation is needed, which is why it seemed like I wasn't using one, but technically I was, but this doesn't really matter). Unfortunately the changes in the .proto file are not "automatically" propagated to the generated .java files, you need to manually run Maven or trigger the project to be built in Eclipse (instructions below), but fortunately the target/generated-sources file is not vanishing or emptying or anything strange like what you describe.
If you want to rebuild the
.javafiles from the.protoclasses without usingmvn clean compilefrom the command line you can clean the Eclipse project . Project → Clean... → select your project → Select build option (only shows if you have "Build Automatically" from the Project menu is unchecked).
I was able to do this in the latest Eclipse Neon (it will probably work in later ones too, but I don't know for certain).
Below is the POM I am using. I don't think it requires any special explanation, my solution is to simply use a different plugin than the one you are using. (If some explanation is needed I'll be happy to provide it though.)
4.0.0
io.github.jacksonbailey
protobuf-m2e-sample
0.1.0-SNAPSHOT
com.google.protobuf
protobuf-java
3.1.0
com.github.os72
protoc-jar-maven-plugin
3.1.0.1
generate-sources
run
3.1.0
src/main/resources