Maven阶段执行两次

Bob*_*mon 11 plugins phase maven

我需要生成一些源代码,因此我将插件目标附加到generate-sources生命周期阶段.

当我运行mvn包它工作正常,但是当我运行mvn install时,我注意到我的源生成插件执行了两次.

        <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>
Run Code Online (Sandbox Code Playgroud)

有什么想法来解决这个问题吗?

Yuv*_*mar 8

我有一个类似的问题,因为我使用了maven-source-plugin解决方案是将目标改为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>
Run Code Online (Sandbox Code Playgroud)