I have an ant task that executes some command on a list of files.
I would like, on consecutive builds, to avoid from re-running the command on files that have passed the command with success and haven’t changed.
For example: (here the command is xmllint)
<target name="xmllint-files">
<apply executable="xmllint">
<srcfile/>
<fileset dir="." includes="*.xml">
<modified/>
</fileset>
</apply>
</target>
The problem is that even the files where xmlint fails are considered as modified and therefore xmllint will not be re-run on them on consecutive builds. Obviously, this is not the desired behavior.
Two remarks:
- I am looking for a general solution and not only a solution for
xmllint. - I want to solve the problem totally inside
antwithout creating
external scripts.
This code uses the Groovy ANT task to do the following:
Example:
Note:
Original answer
Use the ANT modified selector
A property file called “cache.properties” will be created in the build directory. It records file digests, used determine if the file has been changed since the last build run.