Closed paulvi closed 7 years ago
Eclipse integration does exist in the plugin, but it is supported on a 'best effort' basis. There is no specific configuration that is required in Eclipse, everything should work out of the box.
Maybe it is a known configuration problem in your case:
clearOutputDirectory -- this is set to true
by default (for legacy reasons), and you will need to override it as false
.
If that does not help, I'll need more information about your environment and your project. Such as: Maven version, plugin version, Eclipse version and a gist with your POM file.
Mind you, m2e-protoc-connector
, mentioned in StackOverflow question, was built for older versions of Eclipse (more than 3-4 years old now). This integration mechanism is pretty likely not supported anymore in the latest versions.
First, I tried today on base example https://github.com/paulvi/com.example.grpc.maven
<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.4.1.Final</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.0</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.1.0:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.0.1:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
On initial import it is like
than after Alt+F5 like (output folders are empty, and pom.xml with error)
If I run mvn package
and refresh Eclipse, it goes great.
But after project cleaning, it is again without generated Java
Project -> Build (or Project -> Build all) does not add generated Java sources
(thus real project would turn into red)
Can you please confirm that you've followed the steps here: https://github.com/trustin/os-maven-plugin#issues-with-eclipse-m2e-or-other-ides
Then you'll need to add
<clearOutputDirectory>false</clearOutputDirectory>
to the configuration
section.
If everything fails, I am afraid it might be the same problem as we discussed in #10
I got this solved http://stackoverflow.com/questions/40426366/automatically-generate-java-from-proto-with-maven-m2e-in-eclipse-ide/40551763#40551763
Yes, it still does not generate on import / cold eclipse build,
but it is already big step as now I can say to developers "just try to Project Clean" or mvn compile
I have not used/ tried <clearOutputDirectory>false</clearOutputDirectory>
as I believe there should be clearing before generation.
ref #18
...or you can say to your developers "Just give IntelliJ IDEA a go, and forget about the pain that is Eclipse" :)
As someone else noticed on that SO thread, Maven integration in Eclipse is a right royal PITA, and most of the time it gets in the way, rather than helps. I think Eclipse is trying to be clever there, but, unfortunately, it way too often fails at that.
Thank you for the feedback though, and for the effort to reproduce the issue. At least we have a partial solution, and in a way it proves my theory that the problem has got more to do with os-maven-plugin
rather than protobuf-maven-plugin
.
If there's anybody in the community, who a) is actively using Eclipse, b) understands its inner workings and c) is willing to investigate and fix this issue, pull requests will be much appreciated.
Btw, don't take my little rant to the heart, it was not meant to start an IDE war. I fully realise that some people or teams do not have a choice of IDE, or locked into a particular IDE by the tech used in their project, or have been long time users of a particular IDE and are unwilling to switch and relearn. I have been in a situation like that, when I had to use an Eclipse-based IDE in one of the projects, and it had been really painful, not least because of poor Maven integration.
It is OK. IDEA is commercial product (and CE to attract users) while Eclipse IDE is free open source, and sometime feels like DIY "do it yourself".
I could be known for @Nodeclipse, but it went over my view, that should be standard/recommended IDE in team or company. So far I am recommending Eclipse for Java. I am in China. I see IDEA is possibly more popular in Europe now. It is close to 50/50 globally, so yes there may be some bloody wars, and unconstrained minds.
In the end I have a team of 12 Chinese developers, that use Eclipse. And possibly have not tried other or talked about that.
Paul, I am going to close this for now. If you have any feedback on the bug you raised against Eclipse, please feel free to comment here or reopen.
Could you reference how to configure Eclipse to generate sources automatically
also asked on http://stackoverflow.com/questions/40426366/automatically-generate-java-from-proto-with-maven-m2e-in-eclipse-ide