The solution for the build listener that Rebse points to looks useful (+1).
An alternative that you might consider would be to “overload” your goals, something like this:
<project default="compile"> <target name="compile" depends="-compile, cleanUpLib" description="compile and cleanup"/> <target name="-compile"> </target> <target name="deploywar" depends="-deploywar, cleanUpLib" description="deploywar and cleanup"/> <target name="-deploywar"> </target> <target name="cleanUpLib"> </target> </project>
Of course, you cannot overload Ant assemblies into a single file, so target names must be different.
(I used the “-” prefix above, which is a hacker to create “private” targets — that is, you cannot call them from the command line because of shell shell script processing. But, of course, you could double-click them successfully in Ant).
source share