Issue
I want to do a "javac" inside an antrun plugin based on the availability of a file. How do we add conditions inside the maven-antrun plugin.
Solution
You can do this with help of href="http://maven.apache.org/plugins/maven-antrun-plugin/" rel="nofollow noreferrer">Maven AntRun Plugin.
In the sample ant script executes on clean phase and Ant-Contrib library was used:
<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>
You can also view this link: How to execute tasks conditionally using the maven-antrun-plugin?
Answered By - Alex K
Answer Checked By - Clifford M. (JavaFixing Volunteer)