Default and Propeties based on a Prefix supplied with ant command
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   ashutosh_khandelwal
Posted On:   Tuesday, August 31, 2004 11:24 AM

I would like to use some default properties such as host.name = hostName host.number = 8802 host.ipaddress = 111.11.11.11 In addition, I would also like to use some properties defined on the basis of prefix, such as local.host.name = localhost local.host.number = 7001 I would like use these properties in such a way that default (without prefix) values are used if the specific (prefixed) properties are not found. Any ideas about how I can do this without writing my own Ant Task. Thanks,    More>>


I would like to use some default properties such as



host.name = hostName

host.number = 8802

host.ipaddress = 111.11.11.11



In addition, I would also like to use some properties defined on the basis of prefix, such as




local.host.name = localhost

local.host.number = 7001





I would like use these properties in such a way that default (without prefix) values are used if the specific (prefixed) properties are not found.





Any ideas about how I can do this without writing my own Ant Task.

Thanks,

   <<Less

Re: Default and Propeties based on a Prefix supplied with ant command

Posted By:   ashutosh_khandelwal  
Posted On:   Tuesday, September 21, 2004 12:40 PM

I think your answer solves the exactly the opposite problem .





I would like to be able to specify env.id as part of ant command, and retreive the properties with the env.id prefix (if available) otherwise use default properties values as defined in the properties file:




For example,



Here is the proprty file build.properties





# start of properties file




hostName=local

hostNumber=7001




ext.hostNumber=8008




# end of properties file




Here is the target I would like to execute:




ant -Denv.id=ext use
















Should result in


host name:local


host number:8008







I could do this by writin an ant atrger that removes the prefixes and sets the property. Is there any way to avoid writing an additional nat task.

Re: Default and Propeties based on a Prefix supplied with ant command

Posted By:   Anonymous  
Posted On:   Tuesday, August 31, 2004 10:18 PM

The special/default-value problem can be resolved via properties immutability:



host name: ${local.host.name}


If you set the local.host.name before invokation of use, the statement will be ignored and your value will be used. Otherwise the local.host.name will be set to the default value.
About | Sitemap | Contact