Reputation: 131
I require to generate some sources, so i attached a plugin goal to the generate-sources lifecycle phase.
When I run mvn package it works fine, but when I run mvn install I noticed that my source generation plugin executes twice.
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>generate-sources-id</id>
<phase>generate-sources</phase>
<configuration>
<tasks>
<property name="build.compiler" value="extJavac" />
<ant target="generate-sources-from-ant" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Any ideas to fix the problem ?
Upvotes: 13
Views: 11049
Reputation: 128749
Do you happen to have the jetty plugin bound to pre-integration-test, or perhaps some other plugin bound to a phase somewhere in the package through install range? Maybe the cobertura plugin? Both jetty and cobertura plugins--and others--fork a new build from the main build to do some of their work. That would cause your plugin bound to generate-sources to execute twice. The solution will be different depending on which plugin is causing the problem.
Upvotes: 0
Reputation: 1055
I had a similar issue that was caused because i used maven-source-plugin The solution was to change the goal to jar-no-fork
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
Upvotes: 11