ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <>
Subject Re: nested properties anyone?
Date Thu, 15 Aug 2002 17:54:50 GMT
 From chapter 10 of Java Development with Ant [1] (gotta make my plugs 

Copying properties
In section 3.10.1 we demonstrate an obscure way to dereference property 
values by using Ant's built-in capabilities. The ant-contrib [2] 
<propertycopy> task makes property dereferencing much cleaner and easier 
to understand. We have refactored the example we presented earlier to 
use <propertycopy>:

<target name="propertycopy">
   <property name="X" value="Y"/>
   <property name="Y" value="Z"/>
   <propertycopy name="A" from="${X}"/>
   <echo message="A = ${A}"/>

The value of ${X} is "Y". The from attribute of <propertycopy> refers to 
an Ant property name, "Y" in this example. The value of the property Y 
is "Z", so the output is "A = Z". This is a much nicer alternative than 
using the refid tricks.



Matt Benson wrote:
> Agreed on nested properties expansion.
> -Matt
> --- wrote:
>>>From the list of the predefined properties key=value
>>select one based on the
>>value of some other property and use it as a default
>>I have a list of servers (, where
>>key is an actual hostname
>>(obtained from hostname command) and value is a
>>domain, e.g.
>>I want to determine on which machine I'm running the
>>script and use a full
>>domain name further in the script.
>>1. <property file=""/>
>>2. <exec outputproperty="hostname"
>>3. Now I have a ${hostname} and I want to assign its
>>value to the property
>> that I use in my script. My first
>>reaction was to do this:
>><property name="" refid="${${hostname}}"/>
>>Well it didn't work because curleys are evaluated
>>only once and I'm getting the
>>value of literaly as "${hostname}"
>>Is there any other way? Any way? 
>>And I think that it would be nice feature to
>>reevaluate the nested brackets
>>Bob Stone
>>To unsubscribe, e-mail:  
>>For additional commands, e-mail:
> __________________________________________________
> Do You Yahoo!?
> HotJobs - Search Thousands of New Jobs
> --
> To unsubscribe, e-mail:   <>
> For additional commands, e-mail: <>

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message