ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <>
Subject presetdef/macrodef
Date Wed, 05 Nov 2003 16:21:29 GMT
It may be nice to point out somewhere in these tasks'
propaganda that the "tasks" they define can be largely
interchangeable in invocation.  For example, target
"filter" below will filter a specified file and send
the contents either to the console or to a file
depending on whether the property destfile is set:

<target name="-tocon" unless="destfile">
  <macrodef name="myecho">
    <attribute name="message" />
      <echo taskname="myecho"
            message="Console message:" />
      <echo taskname="myecho" message="${message}" />

<target name="-tofile" if="destfile">
  <presetdef name="myecho">
    <echo file="${destfile}" />

<target name="filter" depends="-tocon,-tofile">

  <loadfile srcFile="${srcfile}" property="message">
    <filterchain refid="myfilter" />
  <myecho message="${message}" />

I found this to be an interesting aspect of <macrodef>
and <presetdef> and just thought I would share.


Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard

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

View raw message