Ant:将相同的文件集复制到多个地方 [英] Ant: copy the same fileset to multiple places

查看:22
本文介绍了Ant:将相同的文件集复制到多个地方的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个 Ant 脚本来将一个文件夹复制到其他几个地方.作为一个好听话的程序员,我不想重复自己.有没有办法获取这样的文件集:

I need an Ant script that will copy one folder to several other places. As a good obedient programmer, I want not to repeat myself. Is there any way of taking a fileset like this:

<copy todir="${target}/path/to/target/1">
    <fileset dir="${src}">
        <exclude name='**/*svn' />
    </fileset>
</copy>

并且将 fileset 存储在一个变量中以便可以重复使用?

And storing the fileset in a variable so it can be re-used?

推荐答案

在文件集上声明一个 id 属性,然后在每个复制任务中引用它.

Declare an id attribute on the fileset and then reference it in each copy task.

例如:

<project name="foo">
  <fileset id="myFileSet" dir="${src}">
    <exclude name='**/*svn' />
  </fileset>
  ...
  <target name="copy1">
    <copy todir="${target}/path/to/target/1">
      <fileset refid="myFileSet"/>
    </copy>
  </target>
  <target name="copy2">
    <copy todir="${target}/path/to/target/2">
      <fileset refid="myFileSet"/>
    </copy>
  </target>
</project>

这篇关于Ant:将相同的文件集复制到多个地方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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