ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antoine Lévy-Lambert <>
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?

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"/>
      <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>

<testing v="This is v">
      <echo>this is a test</echo>

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,


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

View raw message