蚂蚁复制复制命令 [英] ant copy copying order

查看:39
本文介绍了蚂蚁复制复制命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 ant 的新手,我想知道 ant 副本如何决定复制顺序.问题是,我有一个这样的文件夹结构 releases/v1,v2,v3 .将为每个新版本创建文件夹.这些文件夹中的文件名将相似.并且需要将最新版本复制到名为latest"的文件夹中,在这种情况下需要将 v3 复制到latest"中.所以我的逻辑是一一复制到最新"文件夹并覆盖文件,最新的文件将保留在最后.我的代码是这样的.

I am new to ant and i want to know how the ant copy decides the copying order. Problem is, I have a folder structure like this releases/v1,v2,v3 . folders will be created for each new release. and names of the files will be similar in these folders. and it is required to copy the latest release in to a folder called 'latest' in this scenario it will be required to copy v3 into 'latest'. so my logic is to copy one by one into 'latest' folder and override the files and the latest file will be remained at the end. my code is like this.

 <copy todir="${srcdist.layout.dir}/etc/wsdl/latest"  flatten="true" overwrite="true">
 <fileset dir="../../releases">             
 <include name="**/*.wsdl"/>        
 </fileset>
 </copy>

这段代码对我来说很好用(在 centOS 中).它从 v1 开始复制并以 v3 结束.但我怀疑这个复制顺序是否每次都有效.copy todir 是在复制之前对文件夹名称进行排序吗?请帮我.

This code works fine for me (in centOS). it starts copying from v1 and ends in v3. but i feel doubt on this copying order whether this will work every time or not. is copy todir sorting the folder names before copying ? please help me.

推荐答案

我认为在复制时依赖 如何对文件进行排序是不好的.因此,如果您可以尝试更改此逻辑以使用 TimestampSelectorAnt-Contrib 项目 选择最新的 wsdl 文件并只复制这个文件,而不是全部所有版本的文件.可以这样做:

I think it's not good to rely on how <fileset> orders the files when copying. So maybe it's better if you can try to change this logic to use a TimestampSelector from the Ant-Contrib project to select the newest wsdl file and copy only this file, not all the files of all versions. It could be done like:

<timestampselector property="latest.modified">
  <path>
    <fileset dir="../../releases">
      <include name="**/*.wsdl" />
    </fileset>
  </path>
</timestampselector>

<copy todir="${srcdist.layout.dir}/etc/wsdl/latest" file="${latest.modified}"/>

或者从 Ant 1.7.1 开始,您可以使用 Last以获取最新文件.您可以在此处找到示例.

Or since Ant 1.7.1 you can use a Last to get the latest file. Here you can find an example.

这篇关于蚂蚁复制复制命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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