I want to write addtional texts to the Java resource files (combine two .java files to one). And I write a python script to do so.
I also want to automate the steps (combines files, compile, package) using Maven. I am a newbie to Maven, I found that exec-maven-plugin could run the python script.
I tried to set<phase>process-resources</phase> to try to make it start before compile, but Eclipse complained that Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
(execution: default, phase: process-resources)
below is my pom of the exec-maven-plugin:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>process-resources</phase> <!-- Eclipse complains an error here -->
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>python</executable>
<workingDirectory>src/main/python</workingDirectory>
<arguments>
<argument>combine.py</argument>
</arguments>
</configuration>
</plugin>
Anyone know that how could I implement this purpose? Thanks a lot.
This is the Eclipse M2e plugin trick.
Sachin Shekhar Ris right, but the answer is not clear enough for newbies like me. Here comes my understanding:See http://wiki.eclipse.org/M2E_plugin_execution_not_covered.
There are two methods to do so in Eclipse M2e.
use the code listed in
Sachin Shekhar R‘s answer. Notice that this piece of code must under<pluginManagement><plugins>and<pluginManagement>must be inside<plugins>. sample code:This only works in the project.
use the “Quick Fix” feature of the Eclipse M2e plugin. It exists after version 1.0. Find the error in
Problemstab. Right click on it, select “Quick Fix”. There would be a Quick Fix window popping up, select the second optionMark goal exec as ignored in Eclipse build in Eclipse references (experimental).This method would write above code between
<lifecycleMappingMetadata>into workspace profile of lifecyclemapping intoworkspace/.metadata/.plugins/org.eclipse.m2e.core/lifecycle-mapping-metadata.xmlThis works in the entire workspace