ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antoine Lévy-Lambert <anto...@antbuild.com>
Subject Re: properties in macros
Date Sat, 28 Feb 2004 16:00:13 GMT
David Corbin wrote:

>I've started using macros, and I've run into a problem  When the macro needs 
>to set a property, and then refer to that property, I seem to be left with 
>the choice of calling the macro only one time, or not using macros. I need to 
>be able to do something like this: ${bar.@{foo}}, or to be able to have 
>properties last only of the length of the macro "invocation".  Since the 
>former didn't seem to work, how should this be done?
>
>Thanks
>  
>

There is a plan to introduce local properties, this will be what you need.

Your idea of ${@{foo}} works too :
(slightly modified example from the ant manual)

<project name="test">
<macrodef name="testing">
   <attribute name="v" default="NOT SET"/>
   <element name="some-tasks" optional="yes"/>
   <sequential>
      <property name="@{v}" value="bonjour"/>
      <property name="english.@{v}" value="hello"/>
      <echo>v is @{v}</echo>
      <echo>property of name @{v} contains ${@{v}}</echo>
      <echo>property of name english.@{v} contains ${english.@{v}}</echo>
      <some-tasks/>
   </sequential>
</macrodef>

<testing v="This is v">
   <some-tasks>
      <echo>this is a test</echo>
   </some-tasks>
</testing>
</project>

Buildfile: macro.xml

     [echo] v is This is v
     [echo] property of name This is v contains bonjour
     [echo] property of name english.This is v contains hello
     [echo] this is a test

Cheers from Frankfurt am Main,

Antoine


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


Mime
View raw message