2010-11-23 147 views
8

我需要生成一些源代码,所以我将插件目标附加到生成源生命周期阶段。Maven阶段执行两次

当我运行MVN包它工作正常,但是当我运行MVN安装我发现我的源代码的生成插件执行两次。

 <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> 

任何想法来解决这个问题?

+0

可能的重复http://stackoverflow.com/questions/4251488/maven-release-plugin-fails-source-artifacts-getting-deployed-twice – Vadzim 2013-12-10 16:39:31

回答

7

描述的问题,我是因为我使用Maven的源插件 这是造成类似问题的解决方法是改变目标,以JAR-无叉

  <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> 
0

你碰巧有绑定到码头插件预集成测试,或可能在程序包绑定到一个阶段地方一些其他的插件安装通过范围?也许cobertura插件?码头和cobertura插件 - 以及其他人 - 从主版本中分出一个新版本来完成他们的一些工作。这会导致你的插件绑定到生成源执行两次。解决方案将根据哪个插件导致问题而有所不同。