ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dick, Brian E." <Brian.D...@FMR.com>
Subject RE: PropertySet use in macro
Date Wed, 01 Sep 2004 16:32:24 GMT
Let me make my example more complicated. This would not work without transferring the properties.
This is closer to what I want to do with a macro.

   <property name="foo1.p1" value="Hello"/>
   <property name="foo1.p2" value="World"/>

   <propertyset id="foo1.propset">
      <propertyref prefix="foo1"/>
      <mapper type="glob" from="foo1*" to="bar*"/>
   </propertyset>

   <property name="foo2.p1" value="Goodbye"/>
   <property name="foo2.p2" value="World"/>

   <propertyset id="foo2.propset">
      <propertyref prefix="foo2"/>
      <mapper type="glob" from="foo2*" to="bar*"/>
   </propertyset>

   <target name="test_propset">
      <antcall target="test_propset2">
         <propertyset refid="foo1.propset"/>
      </antcall>

      <antcall target="test_propset2">
         <propertyset refid="foo2.propset"/>
      </antcall>
   </target>

   <target name="test_propset2">
      <echo message="bar.p1 is ${bar.p1}"/>
      <echo message="bar.p2 is ${bar.p2}"/>
   </target>

Yields

   test_propset:

   test_propset2:
        [echo] bar.p1 is Hello
        [echo] bar.p2 is World

   test_propset2:
        [echo] bar.p1 is Goodbye
        [echo] bar.p2 is World

-----Original Message-----
From: Jan.Materne@rzf.fin-nrw.de [mailto:Jan.Materne@rzf.fin-nrw.de] 
Sent: Wednesday, September 01, 2004 12:15 PM
To: user@ant.apache.org
Subject: AW: PropertySet use in macro


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
> 

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


Mime
View raw message