ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Simpson" <ssimp...@local.com>
Subject Can ant macrodef expand attributes?
Date Fri, 04 May 2007 23:45:34 GMT
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"/>
    <sequential>
    <echo @{attr}>Running macro</echo>
    </sequential>
  </macrodef>
 
  <target name="foo">
    <foomac attr="file=&quot;bar&quot;"/>
  </target>
</project>

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.
 
 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message