変更のためにディレクトリを見るためのアリのタスクはありますか?
質問
それは私には少し遠いように聞こえますが、変更のためにディレクトリを視聴してから、ディレクトリが変更されたときに特定のアリクラスを実行するためのアリのタスクはありますか?
解決
監視されたディレクトリにファイルを追加または変更できる場合は、このシンプルを使用できます 時代遅れ AntContribからのタスク。
<property name="watched-dir.flagfile"
location="MUST be not in watched dir"/>
<outofdate>
<sourcefiles>
<fileset dir="watched-dir"/>
</sourcefiles>
<targetfiles>
<pathelement location="${watched-dir.flagfile}"/>
</targetfiles>
<sequential>
<!--Tasks when something changes go here-->
<touch file="${watched-dir.flagfile}"/>
</sequential>
</outofdate>
Watched-Dirからファイルが消える可能性がある場合、より複雑な問題があります。WatchedDirのShadow Directory構造を作成し、Watched-Dirと一致しているかどうかを確認することで解決できます。このタスクはより複雑ですが、Shadow Directoryを作成するためのスクリプトを提供します。
<property name="TALK" value="true"/>
<property name="shadow-dir"
location="MUST be not in watched dir"/>
<touch
mkdirs="true"
verbose="${TALK}"
>
<fileset dir="watched-dir">
<patterns/>
<type type="file"/>
</fileset>
<!-- That's the tricky globmapper to make touch task work -->
<globmapper from="*" to="${shadow-dir}/*"/>
</touch>
<!--
Due to how touch task with mapped fileset is implemented, it
truncates file access times down to a milliseconds, so if you
would have used outofdate task on shadow dir it would always
show that something is out of date.
Because of that, touching all files in ${shadow-dir} again fixes
that chicken and egg problem.
-->
<touch verbose="${TALK}">
<fileset dir="${shadow-dir}"/>
</touch>
Shadow Directoryが作成されていると、読者の演習としてディレクトリの一貫性をチェックするタスクを残します。
他のヒント
はい、これを行うアリタスクがあります:
https://github.com/chubbard/watchtask
1.7+が必要です。任意の数のファイルセットを視聴し、どのファイルセットから来たかに応じてターゲットを呼び出すことができます。
使用できるかもしれません を待つ
あなたが望むものを達成するためのタスク。 1つ以上の条件(特定のファイルの存在など)が真になるまでブロックします。
組み合わせることができます 申し込み でのタスク filesset selector
<apply executable="somecommand" parallel="false">
<srcfile/>
<fileset dir="${watch.dir}">
<modified/>
</fileset>
</apply>
ファイルセットは、保存されたMD5チェックサムに対してファイルをチェックします。このチェックを繰り返し実行するには、アリをループに入れる必要があります。これはUNIXで簡単にできます:
while true
> do
> ant
> sleep 300
> done
所属していません StackOverflow