このコードは、次の操作を実行するためにGroovy ANT taskを使用しています。
- は、MD5チェックサムチェックに基づいて処理されるXMLファイルを選択し、カスタムグルーヴィーなセレクタを実装します。ファイルの内容が変更されない限り
- 起動xmllint各ファイルのし、それが正常に完了した場合、チェックサムのストアは、(これはxmllintの再実行を防止
例:。
<project name="demo" default="xmllint">
<!--
======================
Groovy task dependency
======================
-->
<path id="build.path">
<pathelement location="jars/groovy-all-1.8.6.jar"/>
</path>
<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="build.path"/>
<!--
==============================================
Select files to be processed
MD5 checksums located in "checksums" directory
==============================================
-->
<target name="select-files">
<fileset id="unprocessedfiles" dir=".">
<include name="*.xml"/>
<exclude name="build.xml"/>
<scriptselector language="groovy" classpathref="build.path">
def ant = new AntBuilder()
ant.checksum(file:filename, toDir:"checksums", verifyProperty:"isMD5ok")
self.selected = (ant.project.properties.isMD5ok == "false") ? true : false
</scriptselector>
</fileset>
</target>
<!--
=============================================================
Process each file
Checksum is saved upon command success, prevents reprocessing
=============================================================
-->
<target name="xmllint" depends="select-files">
<groovy>
project.references.unprocessedfiles.each { file ->
ant.exec(executable:"xmllint", resultproperty:"cmdExit") {
arg(value:file)
}
if (properties.cmdExit == "0") {
ant.checksum(file:file.toString(), toDir:"checksums")
}
}
</groovy>
</target>
</project>
注:
- この複雑な要件は、元のapply ANTタスクを使用して実装することはできません。 xmllintコマンドへの1回のコールは成功する可能性がありますが、もう1つは失敗する可能性があります。
- "チェックサム"と呼ばれるサブディレクトリが作成され、MD5チェックサムファイルが保存されます。
- グルーヴィージャーをMaven Central
オリジナル答え
使用と呼ばれるプロパティファイルは、 "cache.propertiesは" で作成されますmodified selector
<project name="demo" default="xmllint">
<target name="xmllint">
<apply executable="xmllint">
<srcfile/>
<fileset dir="." includes="*.xml">
<modified/>
</fileset>
</apply>
</target>
</project>
ANTからダウンロードすることができますビルドディレクトリ。ファイルダイジェストを記録し、最後にビルドを実行してからファイルが変更されたかどうかを判断します。
タスクが失敗してもビルドではそのファイルは再実行されません。ビルドをパスしたファイルだけを再実行しないようにする必要があります。 – viebel
これはあなたが尋ねたものではありません。私の唯一の提案はカスタムセレクターです。ファイルダイジェスト(ファイル変更を示す)に加えて、操作の結果も保存する必要があります。 –
私はそれをもっと明確にするために質問を更新しました。 Thx – viebel