ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rhino" <rhi...@sympatico.ca>
Subject Re: Testing multiple values?
Date Wed, 21 Dec 2005 15:19:48 GMT
Excellent! I'm sure I won't be the only one to benefit from this technique.

Hmm, what do you think of having a new section in the manual, along the 
lines of "Advanced Techniques for Ant Users" or "Leveraging Ant" or 
something like that? I'm concerned that people wouldn't be all that likely 
to discover your technique in the antcall article; they may not even realize 
that antcall is something that they'd want to use to handle multiple values 
of a variable.

That's why I think a new section that discusses techniques which combine 
various different tasks might be the way to go....


Rhino

----- Original Message ----- 
From: <Jan.Materne@rzf.fin-nrw.de>
To: <user@ant.apache.org>
Sent: Wednesday, December 21, 2005 9:22 AM
Subject: AW: Testing multiple values?


:-)

Ok, I will add an example with that to <antcall>


Jan

>-----Urspr√ľngliche Nachricht-----
>Von: Rhino [mailto:rhino1@sympatico.ca]
>Gesendet: Mittwoch, 21. Dezember 2005 14:42
>An: Ant Users List
>Betreff: Re: Testing multiple values?
>
>Oh, right, it's all coming back to me! You taught me that
>trick a couple of years back on this list. I hadn't thought of
>that as a solution to my current problem but you're right, it
>would work for that,  too.
>
>Excellent! These 'tricks' make Ant conditional processing much
>more palateable than having to set a property so that you can
>set another property so that you can invoke or bypass another
>target just to display a message. Why aren't these tricks
>documented in the manual? There should really be a section for
>techniques like this....
>
>Rhino
>
>----- Original Message -----
>From: <Jan.Materne@rzf.fin-nrw.de>
>To: <user@ant.apache.org>
>Sent: Wednesday, December 21, 2005 1:05 AM
>Subject: AW: Testing multiple values?
>
>
>Another trick is using
>  <antcall target="handle${script1.result}">
>and provide a couple of targets.
>
>
>Jan
>
>>-----Urspr√ľngliche Nachricht-----
>>Von: Rhino [mailto:rhino1@sympatico.ca]
>>Gesendet: Mittwoch, 21. Dezember 2005 00:07
>>An: Ant Users List
>>Betreff: Re: Testing multiple values?
>>
>>Wow, that's remarkably easy and straightforward, which is not
>>what I expect from Ant when it comes to conditions :-)
>>
>>I'll give this a try and post back if it doesn't work properly.
>>
>>Thank you!!
>>
>>Rhino
>>
>>----- Original Message -----
>>From: "Ondrej Svetlik" <ondrej@svetlik.info>
>>To: "Ant Users List" <user@ant.apache.org>
>>Sent: Tuesday, December 20, 2005 4:52 PM
>>Subject: Re: Testing multiple values?
>>
>>
>>> Well, how about
>>>
>>> <exec />
>>> <fail message="Script1 failed. See Script1.out.">
>>> <condition>
>>> <equals arg1="${script1.result}" arg2="1" />
>>> </condition>
>>> </fail>
>>>
>>> <fail message="WinSCP3 environment not initialized. Please
>>click on the
>>> keyfile and supply the passphrase.">
>>> <condition>
>>> <equals arg1="${script1.result}" arg2="-1073741819" />
>>> </condition>
>>> </fail>
>>>
>>> Best regards,
>>>
>>> Ondrej Svetlik
>>>
>>> Rhino wrote:
>>>> 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="${WinSCP3.com}" os="Windows XP"
>>output="${script1.out}"
>>>> error="${script1.err}"
>>>>
>>>> resultproperty="script1.result"
>>>>
>>>> description="Run a trivial script that doesn't change
>>anything, just to
>>>> show that everything works.">
>>>>
>>>> <arg line="/console /script=${script1.in}"/>
>>>>
>>>> </exec>
>>>>
>>>>
>>>>
>>>> </target>
>>>>
>>>> <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"/>
>>>>
>>>> </condition>
>>>>
>>>> <echo message="script1.result=${script1.result}"/>
>>>>
>>>> <antcall target="upload-Tonge-Script1-errors"/>
>>>>
>>>> </target>
>>>>
>>>> <target name="upload-Tonge-Script1-errors" if="script1.failed">
>>>>
>>>> <fail message="Oops, script ${script1.name} failed on Tonge
>>server. See
>>>> ${script1.out} and ${script1.err}."/>
>>>>
>>>> </target>
>>>>
>>>>
>>>>
>>>> <target name="upload-Tonge-Script2-errors" if="script2.failed">
>>>>
>>>> <fail message="Oops, script ${script2.name} failed on Tonge
>>server. See
>>>> ${script2.out} and/or ${script2.err}."/>
>>>>
>>>> </target>
>>>>
>>>>
>>>> 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.
>>>>
>>>> Rhino
>>>>
>>>>
>>>>
>>>
>>>
>---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>> For additional commands, e-mail: user-help@ant.apache.org
>>>
>>>
>>> -- 
>>> No virus found in this incoming message.
>>> Checked by AVG Free Edition.
>>> Version: 7.1.371 / Virus Database: 267.14.1/207 - Release
>>Date: 19/12/2005
>>>
>>>
>>
>>
>>
>>-- 
>>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: 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
>
>
>-- 
>No virus found in this incoming message.
>Checked by AVG Free Edition.
>Version: 7.1.371 / Virus Database: 267.14.1/207 - Release
>Date: 19/12/2005
>
>
>
>
>-- 
>No virus found in this outgoing message.
>Checked by AVG Free Edition.
>Version: 7.1.371 / Virus Database: 267.14.2/208 - Release
>Date: 20/12/2005
>
>
>---------------------------------------------------------------------
>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


-- 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.2/208 - Release Date: 20/12/2005




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


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


Mime
View raw message