ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Reilly" <>
Subject Local Properties
Date Wed, 22 Aug 2007 11:23:31 GMT
Hi all,
I have updated the local properties patch to
make use of the new PropertyHelper delegate infrastructure.

The idea behind local properties is to provide
isolation of properties within element blocks - like
macrodefs and sequential. The main use case of
course is for macrodefs.

With current macrodefs, there is a number of work-arounds
to handle the fact that ant properties are global and unmodifiable
(i.e. write once).
 1) invent a new name based on attribute values
 2) use ac:var unset="yes"

   for example:
    <macrodef name="remove-log4js">
       <attribute name="destdir">
        <element name="jars" implicit="yes"/>
            <mkdir dir="@{destdir}"/>
            <ac:for parm="jar">
                     <basename property="jarfile-@{jar}" file="@{jar}"/>
                     <remove-log4j srcfile="@{jar}"

or: (2):
                     <ac:var name="jar-base-name" unset="yes"/>
                     <basename property="jar-base-name" file="@{jar}"/>
                     <remove-log4j srcfile="@{jar}"

Both of these methods pollute the global property namespace with properties
that are just mean to be used internally within the macrodef instance.

The <local> property patch makes a property that is only alive within
a particular scope.

So the above code becomes:
                   <local name="jar-base-name"/>
                   <basename property="jar-base-name" file="@{jar}"/>
                   <remove-log4j srcfile="@{jar}"

and on exit from the macro, there would be no "jar-base-name" property.
And it there was a global "jar-base-name" property, it would *not* be
or used within the macrodef.

The <local> patch uses the following elements for block scopeing -
<target> and <sequential>.

(I think that this could be restricted to just <sequential>).


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message