Maven阶段执行两次

发布于 2024-10-03 21:18:46 字数 993 浏览 4 评论 0原文

我需要生成一些源,因此我将一个插件目标附加到生成源生命周期阶段。

当我运行mvn package时,它工作正常,但是当我运行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>

有解决问题的想法吗?

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

愿得七秒忆 2024-10-10 21:18:46

我有一个类似的问题,是因为我使用了 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>

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>
乜一 2024-10-10 21:18:46

您是否碰巧将 jetty 插件绑定到预集成测试,或者将其他插件绑定到安装范围内包中某个阶段?也许是 cobertura 插件? jetty 和 cobertura 插件以及其他插件都从主构建中派生出一个新构建来完成一些工作。这将导致绑定到生成源的插件执行两次。根据导致问题的插件的不同,解决方案也会有所不同。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文