2011-03-14 55 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> 

參考: