13

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 ?

nwalke
  • 3,092
  • 5
  • 32
  • 59
Bob Beamon
  • 131
  • 1
  • 2
  • 6
  • Possible duplicate of http://stackoverflow.com/questions/4251488/maven-release-plugin-fails-source-artifacts-getting-deployed-twice – Vadzim Dec 10 '13 at 16:39

2 Answers2

9

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>
Yuval Rimar
  • 1,005
  • 12
  • 21
0

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.

Ryan Stewart
  • 120,981
  • 20
  • 172
  • 194