Maven阶段执行两次
我需要生成一些源,因此我将一个插件目标附加到生成源生命周期阶段。
当我运行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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我有一个类似的问题,是因为我使用了 maven-source-plugin
解决方案是将目标更改为 jar-no-fork
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
您是否碰巧将 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.