Instead of using org.xolstice.maven.plugins:protobuf-maven-plugin my team used com.github.os72:protoc-jar-maven-plugin to generate message classes. I believe that they are the same, since under the hood they all seem to use Google tools.
I do not use any m2e connectors for this plugin ( Edit: protoc-jar-maven-plugin The m2e connection cable comes with it, so no additional installation is required, so it seemed to me that I did not use one, but technically I was, but it doesn't really matter). Unfortunately, the changes in the .proto file .proto not automatically apply to the generated .java files, you need to manually start Maven or run the project that will be created in Eclipse (instructions below), but, fortunately, the target/generated-sources file does not disappear or not empty, or something strange, like what you describe.
If you want to rebuild .java files from .proto classes without using mvn clean compile from the command line, you can clean up the Eclipse project. Project → Clean ... → select your project → Choose an assembly option (only displayed if you have “Build automatically” in the “Project” menu).
I was able to do this in the latest Eclipse Neon (it will probably work in later versions too, but I don’t know for sure).
Below is the POM I am using. I do not think this requires any special explanation, my solution is to just use a different plugin than the one you are using. (If you need some explanation, I will be happy to provide it, though.)
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>io.github.jacksonbailey</groupId> <artifactId>protobuf-m2e-sample</artifactId> <version>0.1.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>com.google.protobuf</groupId> <artifactId>protobuf-java</artifactId> <version>3.1.0</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>com.github.os72</groupId> <artifactId>protoc-jar-maven-plugin</artifactId> <version>3.1.0.1</version> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>run</goal> </goals> <configuration> <protocVersion>3.1.0</protocVersion> <inputDirectories> <include>src/main/resources</include> </inputDirectories> </configuration> </execution> </executions> </plugin> </plugins> </build> </project>
Captain Man Nov 09 '16 at 15:47 2016-11-09 15:47
source share