Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/359.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java maven antrun:如何迭代文件?_Java_Maven_Maven Antrun Plugin - Fatal编程技术网

Java maven antrun:如何迭代文件?

Java maven antrun:如何迭代文件?,java,maven,maven-antrun-plugin,Java,Maven,Maven Antrun Plugin,我在以下方面树立了一个榜样: 或者,使用ant排除: [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] /ho

我在以下方面树立了一个榜样:

或者,使用ant排除:

[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插件不支持定义多个antrun目标

通过将目标定义移动到单独的ant xml构建文件中来解决

        <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.7</version>
            <executions>
                <execution>
                    <phase>process-test-resources</phase>
                    <configuration>
                        <target>
                            <!-- maven does not support defining more than one target... -->
                            <!-- https://jira.codehaus.org/browse/MANTRUN-86 -->
                            <ant antfile="${basedir}/unzip.xml" />
                        </target>
                    </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>
            </configuration>
        </plugin>            
unzip.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<project name="maven-antrun-" default="main"  >
<target name="main">
  <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
  <foreach param="fileName" target="unzipLibs">
    <path>
      <fileset dir="/home/mark/mysvn/devel/java/misc/maven/antrun-foreach" casesensitive="yes">
        <include name="*.xml"/>
      </fileset>
    </path>
  </foreach>
</target>
<target name="unzipLibs">
  <echo message="${fileName}"/>
</target>
</project>

通过将目标定义移动到单独的ant xml构建文件中来解决

        <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.7</version>
            <executions>
                <execution>
                    <phase>process-test-resources</phase>
                    <configuration>
                        <target>
                            <!-- maven does not support defining more than one target... -->
                            <!-- https://jira.codehaus.org/browse/MANTRUN-86 -->
                            <ant antfile="${basedir}/unzip.xml" />
                        </target>
                    </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>
            </configuration>
        </plugin>            
unzip.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<project name="maven-antrun-" default="main"  >
<target name="main">
  <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
  <foreach param="fileName" target="unzipLibs">
    <path>
      <fileset dir="/home/mark/mysvn/devel/java/misc/maven/antrun-foreach" casesensitive="yes">
        <include name="*.xml"/>
      </fileset>
    </path>
  </foreach>
</target>
<target name="unzipLibs">
  <echo message="${fileName}"/>
</target>
</project>