You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by CheeYang Chau <cy...@gmail.com> on 2008/03/27 06:51:23 UTC

Having problem using property to in macrodef if invoke for more than one time

Hi,

I love the macrodef task. However, it has a weakness.  We must be very
careful if using property within the macrodef.  I face problem with a
macrodef that is more complicated than the following example.  I have
to use dirname and condition in my macrodef, but it cause problem if I
invoke macrodef for more than one time as the property has been set
for the first time.  Here is an example that trying to replay the
situation I face:

	<macrodef name="a">		
		<attribute name="module"/>
		<sequential>						
			<property name="myvalue" value="@{module}"/>
			<echo>${myvalue}</echo>
		</sequential>
	</macrodef>
	
	<target name="build">
		<a module="venus"/>
		<a module="mars"/>
	</target>

I expect the output should be

[echo] venus
[echo] mars

but it turn out:

[echo] venus
[echo] venus

I think this is a common issue using macrodef and there are some
temporary solution to pass a temporary property name to the macrodef.
This is not feasible in my situation as I need to pass more than 5 to
10 properties to my macrodef.

Some other solution is using local property but I couldn't find this
task.  I am using ANT 1.7.0.

Any solution?  Please advice.  Thank you very much.

-- 
Best regards,
Chau Chee Yang

E Stream Software Sdn Bhd
URL: www.sql.com.my
SQL Financial Accounting

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


Re: Having problem using property to in macrodef if invoke for more than one time

Posted by Peter Reilly <pe...@gmail.com>.
On Thu, Mar 27, 2008 at 6:23 AM, CheeYang Chau <cy...@gmail.com> wrote:
> I do run the macrodef in parallel using parallel task. Do you think
>  using var task will work ?
There are lots of tasks that are *not* safe with using in the <parallel> task
and <var> is one of them.

If possible do not use <parallel>

Peter

>
>
>
>  On Thu, Mar 27, 2008 at 2:15 PM, Olivier Gies <ol...@bull.net> wrote:
>  > I recommend using the <var ..> task from ant-contrib. You can se it to
>  >  unset properties in macrodefs, like this:
>  >
>  >  <var name="myvalue" unset="true" />
>  >
>  >  BR,
>  >  Olivier
>  >
>  >
>  >  -------- Original Message  --------
>  >  Subject: Having problem using property to in macrodef if invoke for more
>  >  than one time
>  >
>  >
>  > From: CheeYang Chau <cy...@gmail.com>
>  >  To: user@ant.apache.org
>  >  Date: 27/03/2008 13:52
>  >
>  >  > Hi,
>  >  >
>  >  > I love the macrodef task. However, it has a weakness.  We must be very
>  >  > careful if using property within the macrodef.  I face problem with a
>  >  > macrodef that is more complicated than the following example.  I have
>  >  > to use dirname and condition in my macrodef, but it cause problem if I
>  >  > invoke macrodef for more than one time as the property has been set
>  >  > for the first time.  Here is an example that trying to replay the
>  >  > situation I face:
>  >  >
>  >  >       <macrodef name="a">
>  >  >               <attribute name="module"/>
>  >  >               <sequential>
>  >  >                       <property name="myvalue" value="@{module}"/>
>  >  >                       <echo>${myvalue}</echo>
>  >  >               </sequential>
>  >  >       </macrodef>
>  >  >
>  >  >       <target name="build">
>  >  >               <a module="venus"/>
>  >  >               <a module="mars"/>
>  >  >       </target>
>  >  >
>  >  > I expect the output should be
>  >  >
>  >  > [echo] venus
>  >  > [echo] mars
>  >  >
>  >  > but it turn out:
>  >  >
>  >  > [echo] venus
>  >  > [echo] venus
>  >  >
>  >  > I think this is a common issue using macrodef and there are some
>  >  > temporary solution to pass a temporary property name to the macrodef.
>  >  > This is not feasible in my situation as I need to pass more than 5 to
>  >  > 10 properties to my macrodef.
>  >  >
>  >  > Some other solution is using local property but I couldn't find this
>  >  > task.  I am using ANT 1.7.0.
>  >  >
>  >  > Any solution?  Please advice.  Thank you very much.
>  >  >
>  >
>  >  --
>  >  *Olivier Gies*
>  >
>  >  *Delivery Manager
>  >  Customs & Tax Software Engineering Center
>  >  Bull, Architect of an Open World ^TM
>  >  Phone: +86 (10) 65978001 - Ext 555 *
>  >
>  >  *www.bull.com <http://www.bull.com/>*
>  >
>  >  *This e-mail contains material that is confidential for the sole use of
>  >  the intended recipient. Any review, reliance or distribution by others
>  >  or forwarding without express permission is strictly prohibited. If you
>  >  are not the intended recipient, please contact the sender and delete all
>  >  copies.*
>  >
>  >
>  >  ---------------------------------------------------------------------
>  >  To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>  >  For additional commands, e-mail: user-help@ant.apache.org
>  >
>  >
>
>
>
>
> --
>  Best regards,
>  Chau Chee Yang
>
>  E Stream Software Sdn Bhd
>  URL: www.sql.com.my
>  SQL Financial Accounting
>
>  ---------------------------------------------------------------------
>
>
> 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


Re: Having problem using property to in macrodef if invoke for more than one time

Posted by CheeYang Chau <cy...@gmail.com>.
I do run the macrodef in parallel using parallel task. Do you think
using var task will work ?

On Thu, Mar 27, 2008 at 2:15 PM, Olivier Gies <ol...@bull.net> wrote:
> I recommend using the <var ..> task from ant-contrib. You can se it to
>  unset properties in macrodefs, like this:
>
>  <var name="myvalue" unset="true" />
>
>  BR,
>  Olivier
>
>
>  -------- Original Message  --------
>  Subject: Having problem using property to in macrodef if invoke for more
>  than one time
>
>
> From: CheeYang Chau <cy...@gmail.com>
>  To: user@ant.apache.org
>  Date: 27/03/2008 13:52
>
>  > Hi,
>  >
>  > I love the macrodef task. However, it has a weakness.  We must be very
>  > careful if using property within the macrodef.  I face problem with a
>  > macrodef that is more complicated than the following example.  I have
>  > to use dirname and condition in my macrodef, but it cause problem if I
>  > invoke macrodef for more than one time as the property has been set
>  > for the first time.  Here is an example that trying to replay the
>  > situation I face:
>  >
>  >       <macrodef name="a">
>  >               <attribute name="module"/>
>  >               <sequential>
>  >                       <property name="myvalue" value="@{module}"/>
>  >                       <echo>${myvalue}</echo>
>  >               </sequential>
>  >       </macrodef>
>  >
>  >       <target name="build">
>  >               <a module="venus"/>
>  >               <a module="mars"/>
>  >       </target>
>  >
>  > I expect the output should be
>  >
>  > [echo] venus
>  > [echo] mars
>  >
>  > but it turn out:
>  >
>  > [echo] venus
>  > [echo] venus
>  >
>  > I think this is a common issue using macrodef and there are some
>  > temporary solution to pass a temporary property name to the macrodef.
>  > This is not feasible in my situation as I need to pass more than 5 to
>  > 10 properties to my macrodef.
>  >
>  > Some other solution is using local property but I couldn't find this
>  > task.  I am using ANT 1.7.0.
>  >
>  > Any solution?  Please advice.  Thank you very much.
>  >
>
>  --
>  *Olivier Gies*
>
>  *Delivery Manager
>  Customs & Tax Software Engineering Center
>  Bull, Architect of an Open World ^TM
>  Phone: +86 (10) 65978001 - Ext 555 *
>
>  *www.bull.com <http://www.bull.com/>*
>
>  *This e-mail contains material that is confidential for the sole use of
>  the intended recipient. Any review, reliance or distribution by others
>  or forwarding without express permission is strictly prohibited. If you
>  are not the intended recipient, please contact the sender and delete all
>  copies.*
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>  For additional commands, e-mail: user-help@ant.apache.org
>
>



-- 
Best regards,
Chau Chee Yang

E Stream Software Sdn Bhd
URL: www.sql.com.my
SQL Financial Accounting

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


Re: Having problem using property to in macrodef if invoke for more than one time

Posted by Olivier Gies <ol...@bull.net>.
I recommend using the <var ..> task from ant-contrib. You can se it to 
unset properties in macrodefs, like this:

<var name="myvalue" unset="true" />

BR,
Olivier

-------- Original Message  --------
Subject: Having problem using property to in macrodef if invoke for more 
than one time
From: CheeYang Chau <cy...@gmail.com>
To: user@ant.apache.org
Date: 27/03/2008 13:52

> Hi,
> 
> I love the macrodef task. However, it has a weakness.  We must be very
> careful if using property within the macrodef.  I face problem with a
> macrodef that is more complicated than the following example.  I have
> to use dirname and condition in my macrodef, but it cause problem if I
> invoke macrodef for more than one time as the property has been set
> for the first time.  Here is an example that trying to replay the
> situation I face:
> 
> 	<macrodef name="a">		
> 		<attribute name="module"/>
> 		<sequential>						
> 			<property name="myvalue" value="@{module}"/>
> 			<echo>${myvalue}</echo>
> 		</sequential>
> 	</macrodef>
> 	
> 	<target name="build">
> 		<a module="venus"/>
> 		<a module="mars"/>
> 	</target>
> 
> I expect the output should be
> 
> [echo] venus
> [echo] mars
> 
> but it turn out:
> 
> [echo] venus
> [echo] venus
> 
> I think this is a common issue using macrodef and there are some
> temporary solution to pass a temporary property name to the macrodef.
> This is not feasible in my situation as I need to pass more than 5 to
> 10 properties to my macrodef.
> 
> Some other solution is using local property but I couldn't find this
> task.  I am using ANT 1.7.0.
> 
> Any solution?  Please advice.  Thank you very much.
> 

-- 
*Olivier Gies*

*Delivery Manager
Customs & Tax Software Engineering Center
Bull, Architect of an Open World ^TM
Phone: +86 (10) 65978001 - Ext 555 *

*www.bull.com <http://www.bull.com/>*

*This e-mail contains material that is confidential for the sole use of
the intended recipient. Any review, reliance or distribution by others
or forwarding without express permission is strictly prohibited. If you
are not the intended recipient, please contact the sender and delete all
copies.*


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


Re: Having problem using property to in macrodef if invoke for more than one time

Posted by CheeYang Chau <cy...@gmail.com>.
>  <?xml version="1.0" encoding="utf-8"?>
>
>  <project name="ant_dev_problem" default="build">
>     <scriptdef name="beanSetProperty" language="beanshell">
>         <!-- setProperty appears *not* to respect Ant's property,
>              immutability.  Appears to be a change in 1.7.0.
>              Note that setNewProperty *does* respect immutability -->
>         <attribute name="name"/>
>         <attribute name="value"/>
>         <![CDATA[
>                  String n = attributes.get("name");
>                  String v = attributes.get("value");
>                  project.setProperty(n, v);
>         ]]>
>     </scriptdef>
>
>
>
>     <macrodef name="a">
>         <attribute name="module"/>
>         <sequential>
>             <beanSetProperty name="myvalue" value="@{module}" />
>             <echo>inside macro: ${myvalue}</echo>
>
>         </sequential>
>     </macrodef>
>
>     <target name="build">
>         <a module="venus"/>
>         <echo>outside macro: ${myvalue}</echo>
>         <a module="mars"/>
>         <echo>outside macro: ${myvalue}</echo>
>     </target>
>  </project>
>
>  $ ant -q
>      [echo] inside macro: venus
>      [echo] outside macro: venus
>      [echo] inside macro: mars
>      [echo] outside macro: mars
>
>  BUILD SUCCESSFUL
>  Total time: 0 seconds

Your solution works only on sequential processing.  If I run the task
in parallel, I get unexpected result:

   <target name="build">
   	<parallel>
           <a module="venus"/>
           <echo>outside macro: ${myvalue}</echo>
           <a module="mars"/>
           <echo>outside macro: ${myvalue}</echo>
	</parallel>
   </target>

-- 
Best regards,
Chau Chee Yang

E Stream Software Sdn Bhd
URL: www.sql.com.my
SQL Financial Accounting

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


RE: Having problem using property to in macrodef if invoke for more than one time

Posted by Cyril Sagan <Cy...@sas.com>.
You could also use beanshell.  Not sure if this works due to a bug or feature.
We use it very sparingly in our build process (analagous to like goto in C).

<?xml version="1.0" encoding="utf-8"?>

<project name="ant_dev_problem" default="build">
    <scriptdef name="beanSetProperty" language="beanshell">
        <!-- setProperty appears *not* to respect Ant's property,
             immutability.  Appears to be a change in 1.7.0.
             Note that setNewProperty *does* respect immutability -->
        <attribute name="name"/>
        <attribute name="value"/>
        <![CDATA[
                 String n = attributes.get("name");
                 String v = attributes.get("value");
                 project.setProperty(n, v);
        ]]>
    </scriptdef>


    <macrodef name="a">
        <attribute name="module"/>
        <sequential>
            <beanSetProperty name="myvalue" value="@{module}" />
            <echo>inside macro: ${myvalue}</echo>
        </sequential>
    </macrodef>

    <target name="build">
        <a module="venus"/>
        <echo>outside macro: ${myvalue}</echo>
        <a module="mars"/>
        <echo>outside macro: ${myvalue}</echo>
    </target>
</project>

$ ant -q
     [echo] inside macro: venus
     [echo] outside macro: venus
     [echo] inside macro: mars
     [echo] outside macro: mars

BUILD SUCCESSFUL
Total time: 0 seconds

Hope this helps.

--Cyril


-----Original Message-----
From: CheeYang Chau [mailto:cychau@gmail.com]
Sent: Thursday, March 27, 2008 1:51 AM
To: user@ant.apache.org
Subject: Having problem using property to in macrodef if invoke for more than one time

Hi,

I love the macrodef task. However, it has a weakness.  We must be very
careful if using property within the macrodef.  I face problem with a
macrodef that is more complicated than the following example.  I have
to use dirname and condition in my macrodef, but it cause problem if I
invoke macrodef for more than one time as the property has been set
for the first time.  Here is an example that trying to replay the
situation I face:

        <macrodef name="a">
                <attribute name="module"/>
                <sequential>
                        <property name="myvalue" value="@{module}"/>
                        <echo>${myvalue}</echo>
                </sequential>
        </macrodef>

        <target name="build">
                <a module="venus"/>
                <a module="mars"/>
        </target>

I expect the output should be

[echo] venus
[echo] mars

but it turn out:

[echo] venus
[echo] venus

I think this is a common issue using macrodef and there are some
temporary solution to pass a temporary property name to the macrodef.
This is not feasible in my situation as I need to pass more than 5 to
10 properties to my macrodef.

Some other solution is using local property but I couldn't find this
task.  I am using ANT 1.7.0.

Any solution?  Please advice.  Thank you very much.

--
Best regards,
Chau Chee Yang

E Stream Software Sdn Bhd
URL: www.sql.com.my
SQL Financial Accounting

---------------------------------------------------------------------
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


Re: Having problem using property to in macrodef if invoke for more than one time

Posted by CheeYang Chau <cy...@gmail.com>.
Yes. This is what I do now. Using antcall is safe for parallel task.
I also use macrodef but only to organize tasks that don't produce
property.  In this case, my ant script is always safe to run in
parallel and invoke macrodef for more than one time in same target.

On Fri, Mar 28, 2008 at 11:09 AM, David Weintraub <qa...@gmail.com> wrote:
> As you've discovered: Once a property is set, it is set forever. You
>  can use the "var" task, but it isn't safe for parallel use. The other
>  way is to append the module's name onto the end of the property name.
>
>  Another solution is to use <antcall> instead of macrodef. The
>  <antcall> task gives you the similar power to <macrodef> but allows
>  you to reset property values:
>
>  Example:
>  <project name="myapp" default="test" basedir=".">
>      <target name="test">
>          <!-- Call Target <foo> twice with different parameters -->
>          <antcall target="foo">
>              <param name="first" value="foo_first"/>
>              <param name="second" value="foo_second"/>
>          </antcall>
>          <antcall target="foo">
>              <param name="first" value="bar_first"/>
>              <param name="second" value="bar_second"/>
>          </antcall>
>      </target>
>
>      <target name="foo">
>          <!-- Set property "testme" and see if it changes between the
>  two <antcall> calls -->
>          <property name="testme" value="${first}"/>
>          <echo message="testme = ${testme} first = ${first} second =
>  ${second}"/>
>      </target>
>  </project>
>
>
>  Output:
>
>  test:
>
>  foo:
>      [echo] testme = foo_first first = foo_first second = foo_second
>
>  foo:
>      [echo] testme = bar_first first = bar_first second = bar_second
>
>  Note that the value of the property testme changed between the two
>  calls to <antcall>.
>
>
>
>  On Thu, Mar 27, 2008 at 1:51 AM, CheeYang Chau <cy...@gmail.com> wrote:
>  > Hi,
>  >
>  >  I love the macrodef task. However, it has a weakness.  We must be very
>  >  careful if using property within the macrodef.  I face problem with a
>  >  macrodef that is more complicated than the following example.  I have
>  >  to use dirname and condition in my macrodef, but it cause problem if I
>  >  invoke macrodef for more than one time as the property has been set
>  >  for the first time.  Here is an example that trying to replay the
>  >  situation I face:
>  >
>  >         <macrodef name="a">
>  >                 <attribute name="module"/>
>  >                 <sequential>
>  >                         <property name="myvalue" value="@{module}"/>
>  >                         <echo>${myvalue}</echo>
>  >                 </sequential>
>  >         </macrodef>
>  >
>  >         <target name="build">
>  >                 <a module="venus"/>
>  >                 <a module="mars"/>
>  >         </target>
>  >
>  >  I expect the output should be
>  >
>  >  [echo] venus
>  >  [echo] mars
>  >
>  >  but it turn out:
>  >
>  >  [echo] venus
>  >  [echo] venus
>  >
>  >  I think this is a common issue using macrodef and there are some
>  >  temporary solution to pass a temporary property name to the macrodef.
>  >  This is not feasible in my situation as I need to pass more than 5 to
>  >  10 properties to my macrodef.
>  >
>  >  Some other solution is using local property but I couldn't find this
>  >  task.  I am using ANT 1.7.0.
>  >
>  >  Any solution?  Please advice.  Thank you very much.
>  >
>  >  --
>  >  Best regards,
>  >  Chau Chee Yang
>  >
>  >  E Stream Software Sdn Bhd
>  >  URL: www.sql.com.my
>  >  SQL Financial Accounting
>  >
>
> >  ---------------------------------------------------------------------
>  >  To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>  >  For additional commands, e-mail: user-help@ant.apache.org
>  >
>  >
>
>
>
>  --
>  --
>  David Weintraub
>  qazwart@gmail.com
>
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>  For additional commands, e-mail: user-help@ant.apache.org
>
>



-- 
Best regards,
Chau Chee Yang

E Stream Software Sdn Bhd
URL: www.sql.com.my
SQL Financial Accounting

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


Re: Having problem using property to in macrodef if invoke for more than one time

Posted by David Weintraub <qa...@gmail.com>.
As you've discovered: Once a property is set, it is set forever. You
can use the "var" task, but it isn't safe for parallel use. The other
way is to append the module's name onto the end of the property name.

Another solution is to use <antcall> instead of macrodef. The
<antcall> task gives you the similar power to <macrodef> but allows
you to reset property values:

Example:
<project name="myapp" default="test" basedir=".">
     <target name="test">
         <!-- Call Target <foo> twice with different parameters -->
         <antcall target="foo">
             <param name="first" value="foo_first"/>
             <param name="second" value="foo_second"/>
         </antcall>
         <antcall target="foo">
             <param name="first" value="bar_first"/>
             <param name="second" value="bar_second"/>
         </antcall>
     </target>

     <target name="foo">
         <!-- Set property "testme" and see if it changes between the
two <antcall> calls -->
         <property name="testme" value="${first}"/>
         <echo message="testme = ${testme} first = ${first} second =
${second}"/>
     </target>
</project>


Output:

test:

foo:
     [echo] testme = foo_first first = foo_first second = foo_second

foo:
     [echo] testme = bar_first first = bar_first second = bar_second

Note that the value of the property testme changed between the two
calls to <antcall>.

On Thu, Mar 27, 2008 at 1:51 AM, CheeYang Chau <cy...@gmail.com> wrote:
> Hi,
>
>  I love the macrodef task. However, it has a weakness.  We must be very
>  careful if using property within the macrodef.  I face problem with a
>  macrodef that is more complicated than the following example.  I have
>  to use dirname and condition in my macrodef, but it cause problem if I
>  invoke macrodef for more than one time as the property has been set
>  for the first time.  Here is an example that trying to replay the
>  situation I face:
>
>         <macrodef name="a">
>                 <attribute name="module"/>
>                 <sequential>
>                         <property name="myvalue" value="@{module}"/>
>                         <echo>${myvalue}</echo>
>                 </sequential>
>         </macrodef>
>
>         <target name="build">
>                 <a module="venus"/>
>                 <a module="mars"/>
>         </target>
>
>  I expect the output should be
>
>  [echo] venus
>  [echo] mars
>
>  but it turn out:
>
>  [echo] venus
>  [echo] venus
>
>  I think this is a common issue using macrodef and there are some
>  temporary solution to pass a temporary property name to the macrodef.
>  This is not feasible in my situation as I need to pass more than 5 to
>  10 properties to my macrodef.
>
>  Some other solution is using local property but I couldn't find this
>  task.  I am using ANT 1.7.0.
>
>  Any solution?  Please advice.  Thank you very much.
>
>  --
>  Best regards,
>  Chau Chee Yang
>
>  E Stream Software Sdn Bhd
>  URL: www.sql.com.my
>  SQL Financial Accounting
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>  For additional commands, e-mail: user-help@ant.apache.org
>
>



-- 
--
David Weintraub
qazwart@gmail.com

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


Re: Having problem using property to in macrodef if invoke for more than one time

Posted by Peter Reilly <pe...@gmail.com>.
On Thu, Mar 27, 2008 at 7:34 AM, CheeYang Chau <cy...@gmail.com> wrote:
> >  A common, if not so nice solution, is to use an attribute value as
>  >  a property name.
>  >
>  >  For example:
>  >
>  >        <macrodef name="a">
>  >                <attribute name="module"/>
>  >                <sequential>
>  >                        <property name="myvalue.@{module}" value="@{module}"/>
>  >                        <echo>${myvalue.@{module}}</echo>
>  >                </sequential>
>  >        </macrodef>
>
>  I am aware of this solution.  I read some old post regarding there is
>  a proposal to add local property.  It seems like it is a way to go but
>  I haven't seen it implement in ANT 1.70 yet.  How is the progress?
Hopefully it will be added for ant 1.8.0.
The code has been updated to use the new property hooks in ant 1.8.0
and the code is not as memory leaking as before.

Peter
>
>  --
>
>
> Best regards,
>  Chau Chee Yang
>
>  E Stream Software Sdn Bhd
>  URL: www.sql.com.my
>  SQL Financial Accounting
>
>  ---------------------------------------------------------------------
>  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


Re: Having problem using property to in macrodef if invoke for more than one time

Posted by CheeYang Chau <cy...@gmail.com>.
>  A common, if not so nice solution, is to use an attribute value as
>  a property name.
>
>  For example:
>
>        <macrodef name="a">
>                <attribute name="module"/>
>                <sequential>
>                        <property name="myvalue.@{module}" value="@{module}"/>
>                        <echo>${myvalue.@{module}}</echo>
>                </sequential>
>        </macrodef>

I am aware of this solution.  I read some old post regarding there is
a proposal to add local property.  It seems like it is a way to go but
I haven't seen it implement in ANT 1.70 yet.  How is the progress?

-- 
Best regards,
Chau Chee Yang

E Stream Software Sdn Bhd
URL: www.sql.com.my
SQL Financial Accounting

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


Re: Having problem using property to in macrodef if invoke for more than one time

Posted by Peter Reilly <pe...@gmail.com>.
On Thu, Mar 27, 2008 at 5:51 AM, CheeYang Chau <cy...@gmail.com> wrote:
> Hi,
>
>  I love the macrodef task. However, it has a weakness.  We must be very
>  careful if using property within the macrodef.  I face problem with a
>  macrodef that is more complicated than the following example.  I have
>  to use dirname and condition in my macrodef, but it cause problem if I
>  invoke macrodef for more than one time as the property has been set
>  for the first time.  Here is an example that trying to replay the
>  situation I face:
>
>         <macrodef name="a">
>                 <attribute name="module"/>
>                 <sequential>
>                         <property name="myvalue" value="@{module}"/>
>                         <echo>${myvalue}</echo>
>                 </sequential>
>         </macrodef>
>
>         <target name="build">
>                 <a module="venus"/>
>                 <a module="mars"/>
>         </target>
>
>  I expect the output should be
>
>  [echo] venus
>  [echo] mars
>
>  but it turn out:
>
>  [echo] venus
>  [echo] venus
>
>  I think this is a common issue using macrodef and there are some
>  temporary solution to pass a temporary property name to the macrodef.
>  This is not feasible in my situation as I need to pass more than 5 to
>  10 properties to my macrodef.
>
>  Some other solution is using local property but I couldn't find this
>  task.  I am using ANT 1.7.0.
>
>  Any solution?  Please advice.  Thank you very much.
A common, if not so nice solution, is to use an attribute value as
a property name.

For example:
       <macrodef name="a">
               <attribute name="module"/>
               <sequential>
                       <property name="myvalue.@{module}" value="@{module}"/>
                       <echo>${myvalue.@{module}}</echo>
               </sequential>
       </macrodef>

Peter
>
>  --
>  Best regards,
>  Chau Chee Yang
>
>  E Stream Software Sdn Bhd
>  URL: www.sql.com.my
>  SQL Financial Accounting
>
>  ---------------------------------------------------------------------
>  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