Java Mailing List Archive

Apache Ant Archive

» Ant Users List
» Ant Developers List
Can ant macrodef expand attributes?

Can ant macrodef expand attributes?

2007-05-04       - By Scott Simpson

I want a macro to expand to an attribute or not depending on whether the
value is an empty string or not. Suppose I have the following script:

<?xml version="1.0"?>
<!DOCTYPE project []>
<project name="foo" default="foo">
 <macrodef name="foomac">
   <attribute name="attr"/>
   <echo @{attr}>Running macro</echo>

 <target name="foo">
   <foomac attr="file=&quot;bar&quot;"/>

I want to optionally include an attribute to the <echo> element if the
parameter is given as the non-empty string (I'm not really doing this
with <echo>. This is an example).

Any other way to do this? Macros seem great for optionally including
elements and parts of strings but not so great for attributes.

©2008 - Jax Systems, LLC, U.S.A.