仅当源文件被修改时,如何执行Ant任务? [英] How to execute an Ant task only when source files have been modified?

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

问题描述

必须有一个简单的方法来做到这一点。我使用蚂蚁构建一个依赖于SWC库的Flex应用程序,该库可以正常工作,除了重建库,无论是否需要。如果库中的任何源文件(* .as,* .mxml)比SWC更新,我该如何告诉蚂蚁才能运行该任务?



我查看了< dependet>,但它似乎只是删除文件,而不是确定是否应该运行任务。 < depend>似乎期望源文件和目标文件之间的一对一关系,而不是一对多关系 - 我有很多输入文件和一个输出文件,但没有中间目标文件。


非常感谢
Alex

解决方案

您可以使用Ant uptodate任务创建属性,只有在该属性执行时才执行其他目标设置。



我不太了解flex,但你可能想要这样的东西:

 <?xml version =1.0encoding =UTF-8?> 
< project name =testdefault =compile>

< target name =checkforchanges>
< uptodate property =nochanges>
< srcfiles dir =。包括= ** / *为/>
< srcfiles dir =。包括= ** / * MXML/>
< mapper to =applaton.flex/>
< / uptodate>
< / target>

< target name =compiledepends =checkforchangesunless =nochanges>
...
< / target>

< / project>


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?

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.

Thanks a lot, Alex

解决方案

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

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天全站免登陆