How to run Ant tasks even if build fails
I have an Ant task which runs if the lock file is not existing.
But if the build fails, then the lock file is not deleted at the end of the task and subsequently the task is not i开发者_如何学Cnvoked from my scheduled jobs.
Is there anyway to handle such that even if build fails, I should be able to call my cleanUp task to delete the lock files?
Look at this: Testing and exception handling with Ant
There is macrodef with trycatch
This sounds to me like something that should be cleaned up at the beginning of any build.
Do you have an init task or some task on which all other tasks depend? I would just put the deletion of that file in there so that it always gets deleted even if a previous build failed.
However, it's a confusing requirement. It doesn't sound very idiomatic. Ordinarily, task execution is controlled through dependency and conditional properties. See the relevant section of the targets section of the manual for more details about if
and unless
. Creating a file is an expensive way to get the functionality already present in ant's core.
精彩评论