My ant project generates an “output” folder which contains the outputs of multiple runs and I would like to diff them all against files located in an “expected” folder (these lasts have the exact the same name as the ones in the output folder). I tried that:
<apply executable="diff">
<fileset dir="${output.dir}" />
<arg value="-u" />
<srcfile />
<arg value="${expected.dir}/" />
<srcfile />
<redirector>
<outputmapper type="merge" to="result.out" />
</redirector>
</apply>
But I have two problems:
First I am not allowed to put two <srclist /> in one <apply>, so how can I use two times the name of the current file treated in one <apply>?
Second I am not able to get the output of my <apply> in one single file. I tried different ways (putting the output argument in the <apply> tag…) but it always seems to only store the last execution of the apply. How can I append the result of each diff in one single file?
And I don’t want to have to install anything else (so no ant-contrib with foreach).
Thanks.
This works for me:
Some explanation:
applytasktargetfileelement lets you specify a second arg that is derived from thesrcfilevia the mapper.outputattribute and setappendtrue. Note that you may need to delete the output file (i.e. truncate it) otherwise on rerun you’ll not get a clean slate.expected.dirand the target file as successive elements, the mapper merges them into a single full path to the ‘right hand’ file for the diff.