我想根据文件的可用性在antrun插件中做一个"javac".我们如何在maven-antrun插件中添加条件.
你可以借助Maven AntRun Plugin来做到这一点.
在示例中,ant脚本在clean阶段执行,并使用了Ant-Contrib库:
<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>
Run Code Online (Sandbox Code Playgroud)
您还可以查看以下链接:如何使用maven-antrun-plugin有条件地执行任务?
| 归档时间: |
|
| 查看次数: |
7494 次 |
| 最近记录: |