You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Paul Munsey (pmunsey)" <pm...@cisco.com> on 2005/08/16 21:27:49 UTC

Conditional tasks

I'm trying to figure out how to call a task, conditionally. From what I see
I can set properties with a condition, but how can I traslate that to a
task. For example, I only want to send mail to people if errors were found
in the build log file. I'll create my own code for parsing the build log,
but depending on the results I may or may not want to send email.
 
Paul Munsey
pmunsey@cisco.com
 

Re: Conditional tasks

Posted by Paul Lynch <ep...@mailblocks.com>.
You can do something like:

<condition property="foundErrors">
     <available file="errorFile"> (or maybe some other condition)
</condition>
<antcall target="sendErrorEmail"/>

...

<target name="sendErrorEmail" if="foundErrors">
     ...
</target>

The "if" means the target will only run if foundErrors was set to true.

    --Paul

-----Original Message-----
From: Paul Munsey (pmunsey) <pm...@cisco.com>
To: 'Ant Users List' <us...@ant.apache.org>
Sent: Tue, 16 Aug 2005 12:27:49 -0700
Subject: Conditional tasks

I'm trying to figure out how to call a task, conditionally. From what I 
see
I can set properties with a condition, but how can I traslate that to a
task. For example, I only want to send mail to people if errors were 
found
in the build log file. I'll create my own code for parsing the build 
log,
but depending on the results I may or may not want to send email.

Paul Munsey
pmunsey@cisco.com



----------------------------------------------
Mailblocks - A Better Way to Do Email
http://about.mailblocks.com/info


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


RE: Conditional tasks

Posted by Moran Ben-David <mo...@place-base.com>.
Look for the <if> task in ant-contrib:

http://ant-contrib.sourceforge.net/

moran

> -----Original Message-----
> From: Paul Munsey (pmunsey) [mailto:pmunsey@cisco.com]
> Sent: Tuesday, August 16, 2005 3:28 PM
> To: 'Ant Users List'
> Subject: Conditional tasks
> 
> I'm trying to figure out how to call a task, conditionally. From what I
> see
> I can set properties with a condition, but how can I traslate that to a
> task. For example, I only want to send mail to people if errors were found
> in the build log file. I'll create my own code for parsing the build log,
> but depending on the results I may or may not want to send email.
> 
> Paul Munsey
> pmunsey@cisco.com
> 


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