3
我想根據文件的可用性在antrun插件中執行「javac」。我們如何在maven-antrun插件中添加條件。向maven-antrun插件添加文件存在條件
我想根據文件的可用性在antrun插件中執行「javac」。我們如何在maven-antrun插件中添加條件。向maven-antrun插件添加文件存在條件
你可以在Maven AntRun Plugin的幫助下做到這一點。
在樣本Ant腳本執行上乾淨相和Ant-Contrib library使用:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>clean</phase>
<configuration>
<tasks>
<taskdef resource="net/sf/antcontrib/antcontrib.properties" />
<if>
<available file="d:\file_to_check.txt"/>
<then>
<echo>The file exists</echo>
</then>
<else>
<echo>The file does not exist</echo>
</else>
</if>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>20020829</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
您還可以查看此鏈接:How to execute tasks conditionally using the maven-antrun-plugin?