当源文件已被修改如何只执行一个Ant任务? [英] How to execute an Ant task only when source files have been modified?
问题描述
必须有一个简单的方法来做到这一点。我使用Ant构建依赖于一个SWC库,但它重建是否需要与否图书馆工作正常Flex应用程序。我该如何告诉ant如果只运行任务的库的源文件(*。如,*的.mxml)比SWC更新?
我看了下&; dependset>但似乎只删除文件,无法确定任务是否应该运行与否。 <依靠>似乎期待在源文件和目标文件,而不是一个一对多的关系之间存在一对一的关系 - 我有很多输入文件和一个输出文件,但没有中间对象文件。
非常感谢,
亚历克斯
您可以使用Ant UPTODATE任务一>中建立一个属性,并执行只有在该属性设置你的其他目标。
我不知道很多有关弹性,但你可能想是这样的:
<?XML版本=1.0编码=UTF-8&GT?;
<项目名称=测试默认值=编译> <目标名称=checkforchanges>
< UPTODATE财产=nochanges>
< srcfiles DIR =。包括=** / *作为。/>
< srcfiles DIR =。包括=** / * MXML/>
<映射器=applicaton.flex/>
< / UPTODATE>
< /目标与GT; <目标名称=编译取决于=checkforchanges除非=nochanges>
...
< /目标与GT;< /项目>
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屋!