ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan.Mate...@rzf.fin-nrw.de
Subject AW: PropertySet use in macro
Date Wed, 01 Sep 2004 16:15:00 GMT
Have you tried?
The main difference between <antcall> and <macrodef> is that
the <ant*> family opens a new scope for properties while 
<macrodef> is inside the same scope as the caller. Therefore
your macro can access the properties without transfering them.

Jan

> -----Urspr√ľngliche Nachricht-----
> Von: Dick, Brian E. [mailto:Brian.Dick@FMR.com]
> Gesendet am: Mittwoch, 1. September 2004 18:04
> An: Ant Users List
> Betreff: PropertySet use in macro
> 
> Is there a way to use a PropertySet as a parameter to a macro in the
> same way you can use a PropertySet as a parameter to a antcall?
> 
> With antcall I can do the following
> 
>    <property name="foo.p1" value="Hello"/>
>    <property name="foo.p2" value="World"/>
> 
>    <propertyset id="foo.propset">
>       <propertyref prefix="foo"/>
>    </propertyset>
> 
>    <target name="test_propset">
>       <antcall target="test_propset2">
>          <propertyset refid="foo.propset"/>
>       </antcall>
>    </target>
> 
>    <target name="test_propset2">
>       <echo message="foo.p1 is ${foo.p1}"/>
>       <echo message="foo.p2 is ${foo.p2}"/>
>    </target>
> 
> And the result is
> 
>    test_propset:
> 
>    test_propset2:
>         [echo] foo.p1 is Hello
>         [echo] foo.p2 is World
> 
> With a macro I would like to do something like the following
> 
>    <property name="foo.p1" value="Hello"/>
>    <property name="foo.p2" value="World"/>
> 
>    <propertyset id="foo.propset">
>       <propertyref prefix="foo"/>
>    </propertyset>
> 
>    <target name="test_propset">
>       <test_propset2 refid="foo.propset"/>
>    </target>
> 
>    <macrodef name="test_propset2">
>       <attribute name="foo.p1"/>
>       <attribute name="foo.p2"/>
> 
>       <sequential>
>          <echo message="foo.p1 is @{foo.p1}"/>
>          <echo message="foo.p2 is @{foo.p2}"/>
>       </sequential>
>    </macrodef>
> 
> And the result would be
> 
>    test_propset:
>         [echo] foo.p1 is Hello
>         [echo] foo.p2 is World
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 

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