ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@yahoo.com>
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" />
    <sequential>
      <echo taskname="myecho"
            message="Console message:" />
      <echo taskname="myecho" message="${message}" />
    </sequential>
  </macrodef>
</target>

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

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

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


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

-Matt

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message