ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Hill <RH...@classmates.com>
Subject RE: Handling exceptions with 'ant' task
Date Fri, 07 Mar 2003 23:11:57 GMT
Thanks, this is exactly what I'm looking for! 

Although, I'm not able to pass a property from the parent ant script to the
cleanup ant script I call in the catch block...how would I do this using the
Antelope 'Try' task?

<project name="Parent Ant Script" default="test" basedir=".">
       .
    <property name="dir.reports.root" value="reports_dir_name" />
       .
    <!-- Run these Canoo tests -->
    <target name="test">
	<try break="no">
        	<ant antfile="test1.xml"/>
        	<ant antfile="test2.xml"/>
		<catch>
		    <ant antfile="exception-cleanup.xml" inheritall="true">
			<property name="property.used.in.exception-cleanup"
value="{dir.reports.root}"/>
		    </ant>
		</catch>
	</try>
         .
         .
         .
    </target>
       .
       .
       .
</project>

-----Original Message-----
From: Dale Anson [mailto:danson@germane-software.com]
Sent: Thursday, March 06, 2003 3:58 PM
To: Ant Users List
Subject: Re: Handling exceptions with 'ant' task


See the try/catch/finally task packaged with Antelope 
(http://antelope.sourceforge.net). Then you can do:

<project name="Parent Ant Script" default="usage" basedir=".">
       .
       .
       .
    <!-- Run these Canoo tests -->
    <target name="test">
	<try break="no">
        	<ant antfile="test1.xml"/>
        	<ant antfile="test2.xml"/>
		<catch>
			<!-- do other processing here -->
		</catch>
	</try>
         .
         .
         .
    </target>
       .
       .
       .
</project>

The break="no" means to continue with test2 even if test1 fails, which 
is handy for what you are doing. The catch block will execute for each 
failed task.

Documentation for the "try" task is at: 
http://antelope.sourceforge.net/manual/bk03ch07.html

Dale Anson



Richard Hill wrote:

>I'm calling a series of ant files that run Canoo tests (see target "test"
>below). If the first test (test1.xml) throws an exception the parent ant
>file stops, which prevent the second test from running. 
>
>What I would like to do is have the parent ant script continue on by
calling
>test2.xml when an exception occurs in the first test. Or even better yet,
if
>the first test throws an exception, run a cleanup task before moving on to
>the next test. 
>
>How would I do this in the parent ant script?
>
>
><project name="Parent Ant Script" default="usage" basedir=".">
>       .
>       .
>       .
>    <!-- Run these Canoo tests -->
>    <target name="test">
>        <ant antfile="test1.xml"/>
>        <ant antfile="test2.xml"/>
>         .
>         .
>         .
>    </target>
>       .
>       .
>       .
></project>
>
>
>Thanks,
>
>- Richard
>
>
>---------------------------------------------------------------------
>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