Can Ant continue when it encounters an error?

I have an Ant target that performs 2 steps in a sequence:

<target name="release"> <antcall target="-compile"/> <antcall target="-post-compile"/> </target> 

With the above script, it exits immediately if the -compile target does not work. "-post-compile" does not get the ability to run. Is there a way to make sure that the second step (-post-compile) is executed even if the 1st (-compile) crashes?

+4
source share
2 answers

I think you are looking

-keep-going (-k)

This will tell Ant to continue building all targets that are independent of the failed target.

+2
source

If you use ant -contrib (which is very common), you can use the try-catch task and put your post-compile call in its finally element.

Also, if you are not using ant -contrib, you can use subant to call your compile target. subant has a subant attribute that can be used to individually ignore failed targets. Many examples of use on the description page.

+2
source

Source: https://habr.com/ru/post/1387286/


All Articles