I have a basic ant script in which I copy a set of files into a directory outside of any target. I would then like to clean those files up after any/all targets have run regardless of dependencies. The main problem I'm having is that the target can be 'compile' or 'deploywar' so I can't just blindly call the 'cleanUp' target from 'compile' because 'deploywar' might get called next. And I can't blindly call from just 'deploywar' because it might not get called. How can I define a target that will get called after all other necessary targets have been completed (either failed or successful)? The 'cleanUpLib' target below is the target I would like to have called after all/any tasks have executed:
<project name="proto" basedir=".." default="deploywar">
...
<copy todir="${web.dir}/WEB-INF/lib">
<fileset dir="${web.dir}/WEB-INF/lib/common"/>
</copy>
<target name="compile">
<!-- Uses ${web.dir}/WEB-INF/lib -->
....
</target>
<target name="clean" description="Clean output directories">
<!-- Does not use ${web.dir}/WEB-INF/lib -->
....
</target>
<target name="deploywar" depends="compile">
<!-- Uses ${web.dir}/WEB-INF/lib -->
....
</target>
<target name="cleanUpLib">
<!-- Clean up temporary lib files. -->
<delete>
<fileset dir="${web.dir}/WEB-INF/lib">
<include name="*.jar"/>
</fileset>
</delete>
</target>