ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anderson, Rob (Global Trade)" <Rob.Ander...@nike.com>
Subject RE: How to dynamically initialize a property at runtime based on the values of other properties initialized using <input> inside a target?
Date Tue, 23 May 2006 23:05:42 GMT
 This was discussed earlier this week. I will paste my comments from
that conversation here. Although my comments are not specific to your
needs I think they will help you figure out what needs to be done. In
your case you would use the input to get the value of ${env} rather than
requiring it on the command line.

Here it is....

Try creating a properties file for each environment. 

dev.properties
===============
webpath=http://localhost:7001/cis-7.6.0

qa.properties
=============
webpath=http://some-server.com:8185/cis-7.6.0

staging.properties
==============
webpath=http://some-server2.com:8185/cis-7.6.0

Then in your build.xml you can load the appropriate properties file
based on the value of another property, like ${env} for example.

build.xml
===========
...
<property file="${env}.properties"/>
...
<!-- make sure the user set the env property when running ant --> <fail
unless="env">You must specify the env property on the command line. For
example:
ant -Denv=dev
</fail>

So based in the value of ${env} you will have a different value for
${webpath}. You can do the same for other environment specific
properties as well.

I hope this helps.

-Rob Anderson

> -----Original Message-----
> From: Guttula, Mohan [mailto:MGuttula@tiaa-cref.org] 
> Sent: Tuesday, May 23, 2006 3:48 PM
> To: Ant Users List
> Subject: How to dynamically initialize a property at runtime 
> based on the values of other properties initialized using 
> <input> inside a target?
> 
> Hello All,
> 
> I have some properties that I'm initilizing by using <input> 
> task in some targets. I want to dynamically initialize the 
> value of some other property inside other target based on the 
> values from other targets. Is this possible?
> 
> Thanks,
> Mohan
> 
> 
> **************************************************************
> This message, including any attachments, contains 
> confidential information intended for a specific individual 
> and purpose, and is protected by law.  If you are not the 
> intended recipient, please contact sender immediately by 
> reply e-mail and destroy all copies.  You are hereby notified 
> that any disclosure, copying, or distribution of this 
> message, or the taking of any action based on it, is strictly 
> prohibited.
> TIAA-CREF
> **************************************************************
> 
> 
> ---------------------------------------------------------------------
> 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


Mime
View raw message