ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rhino" <>
Subject Testing multiple values?
Date Tue, 20 Dec 2005 17:16:22 GMT
How do I handle three different possible values from an 'exec' task when I 
want one value to be ignored and each of the other two values to invoke 
different targets?

I have an exec task that has the parameter resultproperty="script1.result". 
The value of script1.result can be: 0 (indicates that the script worked fine 
without errors); 1 (indicates that the script ran but had errors); 
or -1073741819 (indicates that the WinSCP3 environment was not initialized 
properly; basically, the passphrase hadn't yet been entered so that WinSCP3 
could verify the login).

When script.result is 0, I want to move on to the next target within my 
build. When script.result is 1, I want to fail with the error message 
("Script1 failed. See Script1.out."). When script1.result is
-1073741819, I want to fail with the error message ("WinSCP3 environment not 
initialized. Please click on the keyfile and supply the passphrase.")

My script currently handles the 0 and 1 conditions just fine but I don't 
know how to change my code to handle the third value for script1.result. 
Here is what I have so far:

<target name="upload-Tonge" description="Upload to the Tonge server.">

<echo message="Uploading to Tonge...."/>

<!--echoproperties prefix="server"/-->

<exec executable="${}" os="Windows XP" output="${script1.out}" 


description="Run a trivial script that doesn't change anything, just to show 
that everything works.">

<arg line="/console /script=${}"/>



<target name="check-Script1" depends="upload-Tonge" description="See if 
Script1 worked.">

<echo message="Check script1 result"/>

<condition property="script1.failed">

<equals arg1="${script1.result}" arg2="1"/>


<echo message="script1.result=${script1.result}"/>

<antcall target="upload-Tonge-Script1-errors"/>


<target name="upload-Tonge-Script1-errors" if="script1.failed">

<fail message="Oops, script ${} failed on Tonge server. See 
${script1.out} and ${script1.err}."/>


<target name="upload-Tonge-Script2-errors" if="script2.failed">

<fail message="Oops, script ${} failed on Tonge server. See 
${script2.out} and/or ${script2.err}."/>


Do I need a different condition task to handle the -1073741819 value for 
script1.result? If yes, don't I have to worry about the 'upload-Bongo' task 
executing twice? Or can I modify the existing condition task to invoke two 
different targets based on the non-zero value of script.result, one target 
for script1.result = 1 and a different target for script1.result 
= -1073741819?

Or do I need to change the script more radically and do things a whole 
different way?

I'd prefer to stay with core tasks if at all possible.


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.1/207 - Release Date: 19/12/2005

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

View raw message