Satya
Satya

Reputation: 2124

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 invoked 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?

Upvotes: 3

Views: 2225

Answers (2)

Tim Visher
Tim Visher

Reputation: 12864

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.

Upvotes: 0

Krzysztof Miksa
Krzysztof Miksa

Reputation: 1539

Look at this: Testing and exception handling with Ant
There is macrodef with trycatch

Upvotes: 1

Related Questions