I have been using m2eclipse for 2 years or so and have now switched to m2e.
Unfortunately, this has broken some functionality for me.
In many projects, I have generated Java code, usually generated through a main class in a library project. Here's a typical setup:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>generateDTOs</id>
<phase>generate-sources</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<classpathScope>test</classpathScope>
<mainClass>com.somecompany.SomeCodeGenerator</mainClass>
<arguments>
<argument>${project.build.directory}/generated-sources/foo</argument>
<argument>${project.basedir}/path/to/a/config/file</argument>
<argument>more arguments</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>addDtoSourceFolder</id>
<goals>
<goal>add-source</goal>
</goals>
<phase>process-sources</phase>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/foo</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
Previously, I would just have to import that project with eclipse as a maven project, the code would automatically be executed and the source folder added to the eclipse project.
Now, m2e has installed a "connector" for the buildhelper plugin, so the source folder is created, but I have to manually trigger code generation by executing Run As > Maven > generate-sources
. This is really annoying, I would like the maven build to respond to pom.xml changes, Project > Clean ...
, SVN Updates, Eclipse startup etc. as it previously did.
What can I do to make m2e work like m2eclipse?
You have to tell M2E that it's okay to run your code generator as part of the Eclipse build:
<project>
<build>
[...]
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence
on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<versionRange>[,)</versionRange>
<goals>
<goal>java</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute/>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Notes:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With