<project default="runtest">
<!--touch任务创建一个新的临时文件-->
<target name="init">
<touch file="旧.txt" />
<sleep seconds="2" />
<touch file="新.txt" />
</target>
<target name="检查新.txt的更新">
<uptodate targetfile="新.txt" srcfile="旧.txt" property="新的新" 、>
</target>
<target name="检查旧.txt的更新">
<uptodate targetfile="旧.txt" srcfile="新.txt" property="旧的新" />
</target>
<target name="输出旧的更新" if="旧的新">
<echo message="旧.txt创建的时间更新" />
</target>
<target name="输出新的更新" if=新的新">
<echo message=新.txt创建的时间更新" />
</target>
<target name="runtest" depends="init,检查旧.txt的更新,检查新.txt的更新,输出旧的更新,输出新的更新">
<echo message="done" />
</target>
</project>
<!--touch任务创建一个新的临时文件-->
<target name="init">
<touch file="旧.txt" />
<sleep seconds="2" />
<touch file="新.txt" />
</target>
<target name="检查新.txt的更新">
<uptodate targetfile="新.txt" srcfile="旧.txt" property="新的新" 、>
</target>
<target name="检查旧.txt的更新">
<uptodate targetfile="旧.txt" srcfile="新.txt" property="旧的新" />
</target>
<target name="输出旧的更新" if="旧的新">
<echo message="旧.txt创建的时间更新" />
</target>
<target name="输出新的更新" if=新的新">
<echo message=新.txt创建的时间更新" />
</target>
<target name="runtest" depends="init,检查旧.txt的更新,检查新.txt的更新,输出旧的更新,输出新的更新">
<echo message="done" />
</target>
</project>
转载于:https://blog.51cto.com/chpi1324/1160122