tags:

views:

70

answers:

2

Hi, I'm currently using ANT for building my Java project on a Windows XP machine. In my build.xml file I've defined 3 task and I would like that,in case of fail,a default task be executed before closing the building and exiting (like a recovery procedure). I would like to know if it's possible.

thanks

+1  A: 

Googled and found this. It's basically a try/catch for Ant. Might be worth a look: http://ant-contrib.sourceforge.net/tasks/tasks/trycatch.html

theseion
Thanks for you answer..it looks what I'm looking for but I cannot install ant-contrib. I'm just using the standard ANT
elos
+1  A: 

Never heard of such a property/task, but the follwing just comes to my mind: you could use an additional 'Master' ant script.

  • The master script (a new one) includes all public targets from the original one and delegates the work to the corresponding task in your build script (ant calls)
  • If the delegate fails, the master should be able to recognize the failure and could call the 'clean-up' task (either on the 'master' or on the original build file)
Andreas_D
thanks for your answer. The point is that if I'm able to recognize the failure of the sub-script in the master-script, should not I be able to do it directly with a task in the master?
elos
If you can catch the failure of a task, then you can call another target. But if the ant script stopps because a target fails, then I doubt that you can catch this failure in the same ant script to call another target. (but now I see, you talked about failing tasks, not targets)
Andreas_D