2011-03-14 56 views
0

在我的Maven构建中,我使用antrun插件来调用ant任务。消除maven依赖项重复

 <plugin> 
      <artifactId>maven-antrun-plugin</artifactId> 
      <executions> 
       <execution> 
        <phase>compile</phase> 
        <configuration> 
         <tasks> 
          <property name="plugin_classpath" refid="maven.plugin.classpath" /> 
          <java classname="org.apache.tools.ant.launch.Launcher" 
           fork="true" failonerror="true"> 
           <classpath> 
            <pathelement path="${plugin_classpath}" /> 
           </classpath> 
          </java> 
         </tasks> 
        </configuration> 
        <goals> 
         <goal>run</goal> 
        </goals> 
       </execution> 
      </executions> 

      <dependencies> 
       <!-- DEPENDENCIES FROM PROJECT DUPLICATED HERE --> 
      </dependencies> 
     </plugin> 

我需要复制指定部分中的所有项目依赖项,以便它们可用于ant任务。有没有办法避免这种重复,通过引用项目的依赖性而不是复制粘贴它们?

+0

我想你可以把它取决于你正在构建的人工制品,以及所有依赖关系都会自动添加。 – Augusto 2011-03-14 13:02:51

回答

1

这里是你如何能做到这一点:

<property name="plugin_classpath" refid="maven.plugin.classpath" /> 
<property name="compile_classpath" refid="maven.compile.classpath" /> 
<java classname="org.apache.tools.ant.launch.Launcher" 
     fork="true" failonerror="true"> 
    <classpath> 
     <pathelement path="${plugin_classpath}" /> 
     <pathelement path="${compile_classpath}" /> 
    </classpath> 
</java> 

参考: