蚂蚁文件拷贝在多个文件夹列表均匀 [英] ant copy a list of files evenly across multiple folders

查看:268
本文介绍了蚂蚁文件拷贝在多个文件夹列表均匀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用蚂蚁来驱动一些测试自动化。我有一个具有大约100相同类型的文件的扁平夹。我想送$ P $垫横跨4个文件夹这些文件平均为s $ P $垫跨越几台机器的执行。所以该项目将创建的四个文件夹,并然后通过几百个文件传递一个文件到一个文件夹中运行,然后继续上。文件1变为夹1,2至2,3至3,4至4,5至1等文件的名称和编号将波动。我可以写一个小工具要做到这一点,但是这将是maintanace simplier,如果我能做到这一点的蚂蚁执行的一部分。

I'm using ant to drive some test automation. I have a flattened folder that has about 100 files of the same type. I'd like to spread these files across 4 folders evenly to spread the execution across a few machines. So the project would create the four folders and then run through the hundred files passing one file to a folder and then continue on. file 1 goes to folder 1, 2 to 2, 3 to 3, 4 to 4, 5 to 1, etc. The names and numbers of files will fluctuate. I can write a small utility to do this but it would be simplier for maintanace if I could do this as part of the ant execution.

推荐答案

下面的示例使用的常规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>

注:


  • 使用一个模操作分发中包含的ANT文件集的文件,到不同的目录

  • 在引导的目标是用来下载并安装<一个第三方的任务jar包href=\"http://search.maven.org/#artifactdetails%7Corg.$c$chaus.groovy%7Cgroovy-all%7C2.1.0-beta-1%7Cjar\"相对=nofollow> Maven的中央

  • Use a modulus operation to distribute files contained in the ANT fileset, into different directories
  • The "bootstrap" target is used to download and install the 3rd party task jar from Maven Central

这篇关于蚂蚁文件拷贝在多个文件夹列表均匀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆