ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Don Taylor <donald_l_taylor...@yahoo.com>
Subject Re: Decision making with ANT.
Date Thu, 09 Aug 2001 02:47:16 GMT

--- Mark Soderquist <cosmo@cosmoworx.com> wrote:
> I would like to set the value of a property based on the value of
> another property.  Specifically I have a variable that is being
> passed in on the command line with -D.  I need to examine the value
> of that property and set a different property based on that value. 
> Is this possible?  If so, how can it be done?
> 
> =Mark
> 

OK, suppose you have -Dvar=value1 on the Ant command line. Suppose the
values of var could be value1, value2, and value3. Now define a
property to test the value:

<property name="var.${var}" value="true" />

So you need to test var for 3 different values (let's say), and set
another property accordingly. Here's how you do it:

<target name="test-value1" if="var.value1">
   <!-- Define your property here -->
</target>

<target name="test-value2" if="var.value2">
   <!-- Define your property here -->
</target>

<target name="test-value3" if="var.value3">
   <!-- Define your property here -->
</target>

Now to perform the test all you need is:

<target name="set-property"
depends="test-value1,test-value2,test-value3" />

So when the target "set-property" is invoked your property will be set
according to the value of the property you defined on the command line.
Admittedly it's a bit of a kludge, but that's how it's done.

-- Don


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

Mime
View raw message