I'm extremely new to ant script and i want to find out if my build is successful or not. my main target has two antcalls and i don't know how to check if they were successful or not, in order to evaluate the main target.
run all is my main target
<target name="run all">
<antcall target="Run basic configuration" />
<antcall target="Run custom configuration"/>
i want to add a fail condition for the "run all" target. Each target does check individually if they are successful, but I want to know if the target that calls the ant is unsuccessful in case those two fail. Also, if one fails does the other one get called?
To determine if an antcall is successful requires a more careful definition of what success is. It can mean:
In the first case, you can wrap the execution of your antcall with a trycatch block to catch exceptions. The trycatch task is part of ant-contrib, but that is frequently used in Ant coding. You'd do:
In the second case, you need to pass back to the caller some state that indicates that the code did what you wanted it to do.
Note that the antcall task reloads the ant file (e.g., build.xml), so it can be an expensive operation. There are alternatives to using the antcall task:
In each of the cases above, just set return properties that you can inspect in the calling target to determine whether the called or dependent targets did what you expected them to do.