I have set up an example at https://github.com/jjYBdx4IL/example-maven-project-setups/blob/master/antrun-foreach/pom.xml :
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>process-test-resources</phase>
<configuration>
<tasks>
<taskdef resource="net/sf/antcontrib/antcontrib.properties" />
<foreach target="unzipLibs" param="fileName">
<path>
<fileset dir="${basedir}" casesensitive="yes">
<include name="*.xml"/>
</fileset>
</path>
</foreach>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<!-- <exclusions>
<exclusion>
<artifactId>ant</artifactId>
<groupId>ant</groupId>
</exclusion>
</exclusions>-->
</dependency>
</dependencies>
<configuration>
<target name="unzipLibs">
<echo message="${fileName}" />
</target>
</configuration>
</plugin>
However, no matter what I try, it does not work:
Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (default) on project antrun-foreach: Error executing ant tasks: org.apache.tools.ant.util.FileUtils.getFileUtils()Lorg/apache/tools/ant/util/FileUtils; -> [Help 1]
or, using the ant exclusion:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (default) on project antrun-foreach: An Ant BuildException has occured: The following error occurred while executing this line:
[ERROR] /home/travis/build/jjYBdx4IL/example-maven-project-setups/antrun-foreach/pom.xml:5: Unexpected element "{http://maven.apache.org/POM/4.0.0}project" {antlib:org.apache.tools.ant}project
[ERROR] around Ant part ...<foreach param="fileName" target="unzipLibs">... @ 5:48 in /home/travis/build/jjYBdx4IL/example-maven-project-setups/antrun-foreach/target/antrun/build-main.xml
Moving the ant tasks into an external file did not help.
Update: the issue seems to be that maven-antrun-plugin does not support defining multiple antrun targets...... https://jira.codehaus.org/browse/MANTRUN-86