You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Matt Benson <gu...@yahoo.com> on 2003/11/05 17:21:29 UTC

presetdef/macrodef

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


Re: presetdef/macrodef

Posted by Matt Benson <gu...@yahoo.com>.
Done.

-Matt

--- Stefan Bodewig <bo...@apache.org> wrote:
> On Wed, 5 Nov 2003, Matt Benson
> <gu...@yahoo.com> wrote:
> 
> > It may be nice to point out somewhere in these
> tasks'
> > propaganda that the "tasks" they define can be
> largely
> > interchangeable in invocation.
> 
> Very nice example.  Can you put it on either tasks
> Wiki?
> 
> Stefan
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> dev-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> dev-help@ant.apache.org
> 


__________________________________
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


Re: presetdef/macrodef

Posted by Stefan Bodewig <bo...@apache.org>.
On Wed, 5 Nov 2003, Matt Benson <gu...@yahoo.com> wrote:

> It may be nice to point out somewhere in these tasks'
> propaganda that the "tasks" they define can be largely
> interchangeable in invocation.

Very nice example.  Can you put it on either tasks Wiki?

Stefan

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