ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt_Con...@i2.com
Subject RE: Conditional task execution
Date Wed, 13 Jun 2001 13:28:19 GMT
I don' think he wants to check if the property is set, but rather if the 
property is equal to a certain value.  i.e. something like:

<target name="foo" if="my.property=bar">
</target>

I ended up writing a custom task to do this - basically lets you call one 
target from another based on a simple boolean expression that it evaluates 
(! & | and = between properties).  Its not perfect, i.e. it doesn't handle 
"depends" too well, but as a side effect, it lets me call a target withint 
the same "Ant" unlike the <antcall> task which ends up creating a whole 
new Project object.  This allows me to set/modify properties within the 
call that can then be seen by other targets outside the call (When antcall 
returns, the PRoject it created gets discarded, and thus so do all 
properties you set within the antcall).

<target name="foo_check">
        <calltarget target="foo" if="my.property&!other.property"/>
</target>


Matt

On 06/13/2001 09:08:49 AM "Helliwell, Matthew" wrote:
> 
> You'll be wanting to read that very nice manual and look at the 
if/unless
> parameters to the target task.
> 
> -----Original Message-----
> 
> Is it possible to execute a task only if a property has a specific 
value?

Mime
View raw message