一、概述
uptodate是Ant内置任务,用于比较源文件与目标文件的时间戳。默认情况下,如果目标文件的比源文件新,会将属性值设为true。可以通过value属性将值设为默认值以外的值。单个源文件可以通过srcfile指定,多个源文件可以通过嵌套srcfiles元素指定,但是srcfile属性与srcfiles元素不能同时使用。srcfiles只会匹配文件,如果需要目录也适用,需要嵌套srcresource和dirset元素。
二、属性
property:要设置属性的属性名。
value:要设置的值,默认为true。
srcfile:源文件,即用来检查目标文件的文件。
targetfile:目标文件,即我们想要确定其状态的文件。
三、简单示例
<project>
<uptodate property="cmp" targetfile="build.xml" >
<srcfiles dir="." includes="*.txt"/>
</uptodate>
<target name="test" unless="${cmp}">
<echo>srcfile is newer than targetfile</echo>
</target>
</project>