我想根据文件的可用性在antrun插件中做一个“javac”。我们如何在maven-antrun插件中添加条件。
答案 0 :(得分:7)
您可以在Maven AntRun Plugin的帮助下完成此操作。
在示例中,ant脚本在 clean 阶段执行,并使用了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?