ant-user mailing list archives

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

Hi,

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

see http://ant-contrib.sourceforge.net/tasks/tasks/index.html
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" />
    	</condition>
       <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"
failonerror="false">
...

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

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


or the depending target checks the property with

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


Regards, Gilbert 

-----Original Message-----
From: timujain [mailto:temujain2000@yahoo.com] 
Sent: Friday, August 11, 2006 8:27 AM
To: user@ant.apache.org
Subject: Detecting <target> failure!


Hi there,
How can I detect <target> or <task> failure to call another <target> as
plan
B rather than failing the entire build?
-- 
View this message in context:
http://www.nabble.com/Detecting-%3Ctarget%3E-failure%21-tf2088943.html#a
5757429
Sent from the Ant - Users forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message