ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scot P. Floess" <>
Subject Macrodef attribute expansion question...
Date Wed, 08 Jul 2009 14:14:08 GMT

I have a question about attribute expansion for macrodefs...

Consider the following:

 	<property  name = "myMessage1"  value = "Name1 [@{name}]  value1 = 
 	<property  file = ""/>

 	<macrodef  name = "testOutput">
 		<attribute  name = "name"/>
 		<attribute  name = "value"/>

 			<property  name = "myMessage2"  value = "Name2 
[@{name}]  value2 = [@{value}]"/>
 			<property  name = "myMessage4"  value = 

 			<echo  message = "1:  ${myMessage1}"/>
 			<echo  message = "2:  ${myMessage2}"/>
 			<echo  message = "3:  Name3 [@{name}]  value3 = 
 			<echo  message = "4:  ${myMessage4}"/>
 			<echo  message = "5:  ${myMessage5}"/>

 	<testOutput  name = "foo"  value = "bar"/>

myMessage5=Name5 [@{name}]  value5 = [@{value}]

When run:

Buildfile: build.xml
      [echo] 1:  Name1 [@{name}]  value1 = [@{value}]
      [echo] 2:  Name2 [foo]  value2 = [bar]
      [echo] 3:  Name3 [foo]  value3 = [bar]
      [echo] 4:  Name1 [@{name}]  value1 = [@{value}]
      [echo] 5:  Name5 [@{name}]  value5 = [@{value}]

I was "hoping" for myMessage1, myMessage4 and myMessage5 to be expanded 
based upon the attributes in testOutput.

The reason I am doing this, is I have some macrodef's and am 
internationalizing messages/error messages - some of which include the 
attributes in the messages.

Is there a way to force expansion "at the right time?"

Or, perhaps, is there a better way to do this sort of thing in Ant?  I'm 
not opposed to scripting this in beanshell if need be.

Any help, pointers, or hints is GRATELY appreciated!

Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087 (Home)
919-890-8117 (Work)

Chief Architect JPlate
Chief Architect JavaPIM

Architect Keros

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

View raw message