ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rebhan, Gilbert" <>
Subject RE: Detecting <target> failure!
Date Fri, 11 Aug 2006 07:18:35 GMT


1. ant-contrib has a <try> ... <catch> task

and Logic Tasks / Trycatch

2. some tasks f.e. <exec> have a resultproperty /outproperty
you can check that property with a condition

<condition property="prop">                                         
     <equals arg1="${resultproperty}" arg2="0" />
       <fail unless="prop" message="error -- rc != 0 " /> 

or with ant-contrib if / else / then, example =

<!-- start ksh script -->     
<echo>${kshscript.prefix} activate ${projekt} ${lum} ${earfile}</echo>
<exec executable="${plinkexec}" resultproperty="rc.activate"

you have to use failonerror="false" here if you don't want an instant 
Build failed and handle that error yourself !!

<!-- ...check RC -->
<target name="main" depends="depends" >
<echo>+++ Returncode was_deploy_scm.ksh activate ==> ${rc.activate}
       <equals arg1="${rc.activate}" arg2="0" />
       <echo>+++ RC Shellscript != 0 +++${line.separator}Abbruch :-(
       <fail />

or the depending target checks the property with

<target name="foo" if="${resultproperty}>
<target name="foo" unless="${resultproperty}>

Regards, Gilbert 

-----Original Message-----
From: timujain [] 
Sent: Friday, August 11, 2006 8:27 AM
Subject: Detecting <target> failure!

Hi there,
How can I detect <target> or <task> failure to call another <target> as
B rather than failing the entire build?
View this message in context:
Sent from the Ant - Users forum at

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message