2017-07-06 248 views
0

我使用Maven-Antrun-Plugin 1.8來執行包含<if>的Ant目標。從Maven-Antrun-Plugin調用<if>

我看過ant-contrib是運行這個所必需的,所以我把依賴關係包含到了ant-contrib:ant-contrib:1.0b3。這導致ant:ant:1.5被傳輸加載,這打破了構建。如果我對ant 1.5進行排除,則<if>再次未定義。

總結:我需要一個maven-antrun-plugin的有效依賴列表,它允許我調用<if>

+0

您是否在Ant項目中輸入了ant-contrib任務?提供對ant-contrib-1.0b3.jar的類路徑依賴是不夠的。 –

+0

我是否需要在Maven-Antrun-Plugin中輸入typedef?如果是這樣,怎麼樣? –

+0

不幸的是,我不確定是否與maven集成可能會影響問題。希望不是。如果處理純粹的Ant,你需要的唯一依賴項就是'ant-contrib-1.0b3.jar'。在使用''任務之前,您必須在Ant的'build.xml'中使用'「/>'。 –

回答

1

或許下面可以幫助你的Maven POM:

<dependencies> 
    <dependency> 
     <groupId>ant-contrib</groupId> 
     <artifactId>ant-contrib</artifactId> 
     <version>1.0b3</version> 
     <scope>provided</scope> 
     <exclusions> 
      <exclusion> 
       <groupId>ant</groupId> 
       <artifactId>ant</artifactId> 
      </exclusion> 
     </exclusions> 
    </dependency> 
</dependencies> 
<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-antrun-plugin</artifactId> 
      <version>1.8</version> 
      <executions> 
       <execution> 
        <id>ID_HERE</id> 
        <phase>PHASE_HERE</phase> 
        <goals> 
         <goal>run</goal> 
        </goals> 
        <configuration> 
         <target> 
          <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.plugin.classpath"/> 
          <if> 
           <!-- Some if condition here --> 
           <then> 
            <!-- Ant tasks to execute if condition is true --> 
           </then> 
          </if> 
         </target> 
        </configuration> 
       </execution> 
      </executions> 
      <dependencies> 
       <dependency> 
        <groupId>ant-contrib</groupId> 
        <artifactId>ant-contrib</artifactId> 
        <version>1.0b3</version> 
        <exclusions> 
         <exclusion> 
          <groupId>ant</groupId> 
          <artifactId>ant</artifactId> 
         </exclusion> 
        </exclusions> 
       </dependency> 
      </plugin> 
     </plugins> 
    </build> 

我明白,這可能不是最優的/有效的解決您的問題,但是這正是我目前使用自己和它的沒有問題的作品。

相關問題