Ant では、単純なタスクを達成しようとしています。いくつかのファイルが変更された場合、コンパイラを実行する必要があります。OutOfDate、UpToDate、および Modified を使用した多くのソリューションを見てきました。ファイルが同じ日に変更された場合、タスクを使用できないため、OutOfDate と UpToDate を使用したくありません。modified を使用できますが、修飾子タスクから別のタスク (私のコンパイラ タスク) を呼び出す方法はありません。これら以外に解決策はありますか?
質問する
2774 次
1 に答える
8
<uptodate>
以下<antcall>
を条件付きで使用すると、<target>
探しているものが得られます。
<project name="ant-uptodate" default="run-tests">
<tstamp>
<format property="ten.seconds.ago" offset="-10" unit="second"
pattern="MM/dd/yyyy hh:mm aa"/>
</tstamp>
<target name="uptodate-test">
<uptodate property="build.notRequired" targetfile="target-file.txt">
<srcfiles dir= "." includes="source-file.txt"/>
</uptodate>
<antcall target="do-compiler-conditionally"/>
</target>
<target name="do-compiler-conditionally" unless="build.notRequired">
<echo>Call compiler here.</echo>
</target>
<target name="source-older-than-target-test">
<touch file="source-file.txt" datetime="${ten.seconds.ago}"/>
<touch file="target-file.txt" datetime="now"/>
<antcall target="uptodate-test"/>
</target>
<target name="source-newer-than-target-test">
<touch file="target-file.txt" datetime="${ten.seconds.ago}"/>
<touch file="source-file.txt" datetime="now"/>
<antcall target="uptodate-test"/>
</target>
<target name="run-tests"
depends="source-older-than-target-test,source-newer-than-target-test"/>
</project>
于 2012-06-13T15:35:51.803 に答える