只有在源文件被修改的情况下,如何执行 Ant 任务? [英] How to execute an Ant task only when source files have been modified?

查看:32
本文介绍了只有在源文件被修改的情况下,如何执行 Ant 任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

必须有一个简单的方法来做到这一点.我使用依赖于 SWC 库的 ant 构建了一个 Flex 应用程序,除了它是否需要重建库之外,它工作正常.如果库的任何源文件(*.as、*.mxml)比 SWC 更新,我如何告诉 ant 只运行任务?

There must be an easy way to do this. I build a Flex app using ant that depends on a SWC library, which works fine except that it rebuilds the library whether it needs to or not. How do I tell ant to only run the task if any of the sources files of the library (*.as, *.mxml) are newer than the SWC?

我看过 <dependset> 但它似乎只是删除文件,而不是确定是否应该运行任务.<depend> 似乎期望源文件和目标文件之间存在一对一的关系,而不是一对多的关系——我有许多输入文件和一个输出文件,但没有中间目标文件.

I've looked at <dependset> but it only seems to delete files, not determine whether a task should be run or not. <depend> seems to expect a one-to-one relationship between the source and target files rather than a one-to-many relationship -- I have many input files and one output file, but no intermediate object files.

非常感谢,亚历克斯

推荐答案

您可以使用 Ant 更新任务来创建一个属性,并且仅在设置了该属性时才执行您的其他目标.

You may use the Ant uptodate task to create a property, and execute your other target only if that property is set.

我对 flex 了解不多,但您可能想要这样的东西:

I don't know much about flex, but you probably want something like this:

<?xml version="1.0" encoding="UTF-8"?>
<project name="test" default="compile">

   <target name="checkforchanges">
      <uptodate property="nochanges">
         <srcfiles dir="." includes="**/*.as"/>
         <srcfiles dir="." includes="**/*.mxml"/>
         <mapper to="applicaton.flex"/>
      </uptodate>
   </target>

   <target name="compile" depends="checkforchanges" unless="nochanges">
      ...
   </target>

</project>

这篇关于只有在源文件被修改的情况下,如何执行 Ant 任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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