You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Daniel Modin <da...@handelsbanken.se> on 2009/03/13 16:27:14 UTC

Ang. AW: Read property based on another property

OK, thanks Jan - i think i will follow your suggestion.





<Ja...@rzf.fin-nrw.de> 
2009-03-13 14:26
Sänd svar till
"Ant Users List" <us...@ant.apache.org>


Till
<us...@ant.apache.org>
Kopia

Ärende
AW: Read property based on another property






>In file "deploy.properties" i would like to have properties for deploy 
>directories for different test environments:
>deploy.dir.ft = ft/stage/2
>deploy.dir.st =st/stage/2
>deploy.dir.pt =st/stage/2
>deploy.dir.pr=pr/stage/1
>
>Then i want to read the deploy directory for the current 
>testenvironment!
>
>I tried this:
>
>    <ftp server="ftpserver"
>         remotedir="${deploy.dir.${testenv}}"
>             :
>             :
>   </ftp>
>
>....and offcause it did not work :-)


Your solution is described in the FAQ
http://ant.apache.org/faq.html#propertyvalue-as-name-for-property

I would suggest using multiple properties files
  <property name="environment" value="ft"/> <!-- ft, st, pt, pr ... -->
  <property file="environment.${environment}.properties"/>
With stored properties eg in environment.ft.properties
  deploy.dir=ft/stage/2
  ftp.user=...
  ftp.pwd=...
  ftp.server=...
Same properties (but different values) in the other files.
The simply use
  <ftp server="${ftp.server}" remotedir="${deploy.dir}" ...


Jan


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