You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Morten Mortensen <mo...@tietoenator.com> on 2003/07/06 19:56:25 UTC

Q: Double-expansion - reading environment variables "dynamically" ?

Hi developers,

I seem to have zero luck on the users-list... I am getting pretty
impatient...

To repeat: Given a defined property assigned the name of an
environment-variable, how do I read the value of the
environment-variable?

Can it be done? How?

     ?

Regards,
Morten Sabroe Mortensen


-----Original Message-----
From: Morten Mortensen
To: 'user@ant.apache.org'
Sent: 06-07-03 05:30
Subject: Q: Double-expansion - reading environment variables "dynamically"?


Given a defined property "x" assigned the name of an
environment-variable, how do I read the value of the
environment-variable?


I can read the environment-variable "XXX_HOME" by introducing the
environment as "env" and using "${env.XXX_HOME}" in my Ant-file.

But what if "XXX_HOME" is specified as the value of a property?


Constructed example:

  <target
    name="test"
  >
    <property environment="env"/>

    <!-- Property wired here for the example; is to be read by other
means: -->
    <property name="x" value="XXX_HOME"/>

    <!-- Gee, does some kind of double-expansion work?: -->
    <property name="v" value="${env.${x}}"/>

    <!-- Would like to see the value identical to "${env.XXX_HOME}"
here: -->
    <echo>Result: ${v}</echo>
  </target>


If anyone knows how to do this, please tell me how.

    ?

Morten Sabroe Mortensen 

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


Re: Q: Double-expansion - reading environment variables "dynamically" ?

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
<propertycopy> from the ant-contrib project at Sourceforge is what you 
want.

	Erik

p.s. No need to get impatient after less than a day of posting to the 
user list, especially on a weekend.  Not to mention that this has been 
answered numerous times on the list and the answer is surely in the 
archives and most likely at the jGuru Ant FAQ, and also in the Java 
Development With Ant book.

On Sunday, July 6, 2003, at 10:56  AM, Morten Mortensen wrote:
>
> Hi developers,
>
> I seem to have zero luck on the users-list... I am getting pretty
> impatient...
>
> To repeat: Given a defined property assigned the name of an
> environment-variable, how do I read the value of the
> environment-variable?
>
> Can it be done? How?
>
>      ?
>
> Regards,
> Morten Sabroe Mortensen
>
>
> -----Original Message-----
> From: Morten Mortensen
> To: 'user@ant.apache.org'
> Sent: 06-07-03 05:30
> Subject: Q: Double-expansion - reading environment variables 
> "dynamically"?
>
>
> Given a defined property "x" assigned the name of an
> environment-variable, how do I read the value of the
> environment-variable?
>
>
> I can read the environment-variable "XXX_HOME" by introducing the
> environment as "env" and using "${env.XXX_HOME}" in my Ant-file.
>
> But what if "XXX_HOME" is specified as the value of a property?
>
>
> Constructed example:
>
>   <target
>     name="test"
>>
>     <property environment="env"/>
>
>     <!-- Property wired here for the example; is to be read by other
> means: -->
>     <property name="x" value="XXX_HOME"/>
>
>     <!-- Gee, does some kind of double-expansion work?: -->
>     <property name="v" value="${env.${x}}"/>
>
>     <!-- Would like to see the value identical to "${env.XXX_HOME}"
> here: -->
>     <echo>Result: ${v}</echo>
>   </target>
>
>
> If anyone knows how to do this, please tell me how.
>
>     ?
>
> Morten Sabroe Mortensen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>


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