ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "CheeYang Chau" <cyc...@gmail.com>
Subject Re: Having problem using property to in macrodef if invoke for more than one time
Date Fri, 28 Mar 2008 01:24:40 GMT
>  <?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


Mime
View raw message