Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.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
ant跨多个文件夹均匀复制文件列表_Ant - Fatal编程技术网

ant跨多个文件夹均匀复制文件列表

ant跨多个文件夹均匀复制文件列表,ant,Ant,我正在使用ant来驱动一些测试自动化。我有一个扁平的文件夹,其中有大约100个相同类型的文件。我想将这些文件均匀地分布在4个文件夹中,以便在几台机器上执行。因此,该项目将创建四个文件夹,然后运行一百个文件,将一个文件传递到一个文件夹,然后继续。文件1转到文件夹1、2到2、3到3、4到4、5到1,等等。文件的名称和数量会波动。我可以编写一个小型实用程序来实现这一点,但是如果我可以将此作为ant执行的一部分来实现,那么维护就更简单了。下面的示例使用了非常好地集成到ant构建中的: <proje

我正在使用ant来驱动一些测试自动化。我有一个扁平的文件夹,其中有大约100个相同类型的文件。我想将这些文件均匀地分布在4个文件夹中,以便在几台机器上执行。因此,该项目将创建四个文件夹,然后运行一百个文件,将一个文件传递到一个文件夹,然后继续。文件1转到文件夹1、2到2、3到3、4到4、5到1,等等。文件的名称和数量会波动。我可以编写一个小型实用程序来实现这一点,但是如果我可以将此作为ant执行的一部分来实现,那么维护就更简单了。

下面的示例使用了非常好地集成到ant构建中的:

<project name="demo" default="distribute">

    <target name="bootstrap">
        <mkdir dir="${user.home}/.ant/lib"/>
        <get dest="${user.home}/.ant/lib/groovy-all.jar" src="http://search.maven.org/remotecontent?filepath=org/codehaus/groovy/groovy-all/2.1.0-beta-1/groovy-all-2.1.0-beta-1.jar"/>
    </target>

    <target name="distribute">
        <taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy"/>
        <fileset id="srcFiles" dir="build/src" includes="*.txt"/>
        <groovy>
            def i = 0
            project.references.srcFiles.each {
                ant.copy(file:it, todir:"build/dir/${i % 4}", verbose:true)
                i++
            }
        </groovy>
    </target>

</project>

DEFI=0
project.references.srcFiles.each{
copy(文件:it,todir:“build/dir/${i%4}”,详细说明:true)
我++
}
注:

  • 使用模数操作将ANT文件集中包含的文件分发到不同的目录中
  • “bootstrap”目标用于从下载和安装第三方任务jar