Short code for Antrun Maven plugin
<build>
<plugins>
<plugin> <artifactId>maven-antrun-plugin</artifactId>
<executions> <execution> <phase>initialize</phase> <goals><goal>run</goal></goals> <configuration> <tasks>
<echo> *** Hello from Ant! *** </echo>
</tasks> </configuration> </execution> </executions>
</plugin>
</plugins>
</build>
To use Ant tasks not included in the Ant jar, like Ant optional or custom
tasks, you need to add the dependencies needed for the task to run to the plugin
classpath and use the maven.plugin.classpath reference if needed.
See Using
tasks not included in Ant's default jar
<plugin> <artifactId>maven-antrun-plugin</artifactId>
<executions> <execution> <phase>initialize</phase> <goals><goal>run</goal></goals> <configuration> <tasks>
<echoproperties/>
<mkdir dir="${user.dir}/workdir"/>
</tasks> </configuration> </execution> </executions>
<dependencies>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-optional</artifactId>
<version>1.5.3-1</version>
<type>jar</type>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>maven-properties-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<executions> <execution> <phase>initialize</phase> <goals><goal>write-project-properties</goal></goals> <configuration>
<outputFile>props.txt</outputFile>
</configuration> </execution> </executions>
</plugin>