You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Zhou Wu <zw...@yahoo.com> on 2002/06/28 23:15:03 UTC

A (recusive?) property problem.


  I have a problem like this:
   
   <property name="test1" value="test1" />
   <property name="a.${test1}" value="a.test1" />

  I wonder how I can use the property in second line?

   <property name="test2" value="this is
${a.${test1}}" />

  won't work.

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: A (recusive?) property problem.

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
----- Original Message -----
From: "Diane Holt" <ho...@yahoo.com>

> To do this, you need the ant-contrib <propertycopy> task. See:
>   http://marc.theaimsgroup.com/?l=ant-dev&m=102511219322882&w=2
>
> You'd use like this:
>   <target name="setTest2">
>     <property name="test1" value="test1"/>
>     <property name="a.${test1}" value="a.test1"/>
>     <propertycopy name="test2.tmp" from="${a.test1}"/>
>     <property name="test2" value="this is ${test2.tmp}"/>
>     <echo>test2 = ${test2}</echo>
>   </target>

I much prefer the <propertycopy> task myself, but there is actually a
round-about way to do this with just core Ant:

<property name="X" value="Y" id="X.prop"/>
<property name="Y" value="Z" id="Y.prop"/>
<property name="selector" value="${X}"/>
<property name="A" refid="${selector}.prop"/>
<echo message="A = ${A}"/>

In this case, it would output:

     [echo] A = Z

This is pretty wacky and confusing stuff though, so stick with
<propertycopy>  :))

    Erik





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: A (recusive?) property problem.

Posted by Diane Holt <ho...@yahoo.com>.
--- Zhou Wu <zw...@yahoo.com> wrote:
> I have a problem like this:
>    
> <property name="test1" value="test1" />
> <property name="a.${test1}" value="a.test1" />
> 
> I wonder how I can use the property in second line?
> 
> <property name="test2" value="this is ${a.${test1}}" />
> won't work.

To do this, you need the ant-contrib <propertycopy> task. See:
  http://marc.theaimsgroup.com/?l=ant-dev&m=102511219322882&w=2

You'd use like this:
  <target name="setTest2">
    <property name="test1" value="test1"/>
    <property name="a.${test1}" value="a.test1"/>
    <propertycopy name="test2.tmp" from="${a.test1}"/>
    <property name="test2" value="this is ${test2.tmp}"/>
    <echo>test2 = ${test2}</echo>
  </target>

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>