使用 Ant <modified >具有任意日期的选择器 [英] Use Ant <modified> selector with arbitrary date

查看:17
本文介绍了使用 Ant <modified >具有任意日期的选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为内容迁移项目的一部分,我每周都将内容构建到 CMS 中,并使用 Ant 脚本将内容文件复制到构建目录.到目前为止,我们每次都在擦除 CMS 并重新加载整个 17,000 个文件集,大约需要 1.5 小时.但现在内容和 CMS 自定义更加稳定,我们只想上传自上周以来修改过的内容文件.

As part of a content migration project, I am building content into a CMS on a weekly basis, and I use an Ant script to copy the content files to the build directory. Up until now, we've been wiping the CMS and reloading the whole 17,000-file set every time, which takes about 1.5 hours. But now that the content and the CMS customisations are more stable, we'd like to only upload the content files that have been modified since the previous week.

我可以使用 <modified> 复制自上次运行 Ant 脚本以来修改过的文件.选择器:

I can copy files modified since the last time I ran the Ant script using the <modified> selector:

<copy todir="changed" failonerror="no">
  <fileset dir="output" includes="*.*">
    <modified/>
  </fileset>
</copy>

效果很好.但是,我希望能够加载自上次在服务器上进行 CMS 构建以来已修改的文件.所以我想知道是否有某种方法可以使用 <modified> 的基于缓存的方法来仅复制自给定日期/时间以来已修改的文件,例如上周四 17 点"而不是上次此脚本是运行".

Which works very nicely. However, I would like to be able to load the files that have been modified since the last CMS build that took place on the server. So I was wondering if there was some way of using <modified>'s cache-based approach to only copy the files that have been modified since a given date/time like "17.00 last Thursday" instead of "last time this script was run".

推荐答案

我在 Ant 邮件列表,其中 Stefan Bodewig 建议在 modified 选择器上使用 update 参数.当我使用 Ant 1.7.1 时,我不得不解决一个错误,该错误阻止它直接用作属性,但本质上,通过使用在命令行上设置的属性设置它,我可以随时更新缓存生产构建,并在我进行中间测试构建时保持缓存原样.

I got the answer I was looking for on the Ant mailing list where Stefan Bodewig suggested using the update parameter on the modified selector. As I'm using Ant 1.7.1., I had to work around a bug that prevented its direct use as an attribute, but essentially, by setting it using a property set on the command line, I can update the cache whenever I do a production build, and leave the cache as it is when I do an intermediate test build.

这是我最终得到的代码(包括 1.7.1 的解决方法.):

Here is the code I ended up with (including workaround for 1.7.1.):

<copy todir="\content\Test\" includeEmptyDirs="false" failonerror="no">
  <fileset dir="../Output">
    <modified>
      <param name="update" value="false"/>
    </modified>
  </fileset>
</copy>

这篇关于使用 Ant &lt;modified &gt;具有任意日期的选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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