I have a requirement where I need to delink my symbolic links before my build, and then link them back again at the end end of the successful build. In addition to the linking, I also need to cleanup the environment everytime to remove temporary files etc. It is very difficult and tedious to use depends or antcall in all the targets, especially went the build files are spread around various projects. A final target in the build script would be best to allow such cleanup after the build.
*** Bug 19259 has been marked as a duplicate of this bug. ***
*** Bug 22651 has been marked as a duplicate of this bug. ***
*** Bug 18402 has been marked as a duplicate of this bug. ***
*** Bug 24761 has been marked as a duplicate of this bug. ***
If this Bug 24761 is marked as a dup of this bug, then I have a requirement that this fix includes a property that is set if a the build has failed prior to calling the <final> target. --glenn opdycke-hansen
*** Bug 28620 has been marked as a duplicate of this bug. ***
In the current version of Ant you can create your own target Executor. Actually, I've written it for you: import org.apache.tools.ant.Project; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.helper.DefaultExecutor; /** * Executor that runs a final target. */ public class FinalTargetExecutor extends DefaultExecutor { public void executeTargets(Project project, String[] targetNames) throws BuildException { BuildException be = null; try { super.executeTargets(project, targetNames); } catch (BuildException e) { be = e; } finally { String ft = project.getProperty("finaltarget"); if (ft != null) { try { project.executeTarget(ft); } catch (BuildException e) { project.log(e.getMessage()); } } if (be != null) { throw be; } } } } all you have to do is set the property "finaltarget" to whatever target name you want called. As usual, this can be set inside the buildfile or overridden from the command line. Feel free to modify this to suit your needs.
There is a blurb about executors at "Running Ant" -> "Java System Properties" in the manual. You simply use -Dant.executor.class=classname to set it.
*** Bug 32178 has been marked as a duplicate of this bug. ***