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>
ただし、何を試しても機能しません。
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]
または、アリの除外を使用して:
[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
Ant タスクを外部ファイルに移動しても役に立ちませんでした。
更新: 問題は、maven-antrun-plugin が複数の antrun ターゲットの定義をサポートしていないようです...... https://jira.codehaus.org/browse/MANTRUN-86