ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Reilly <>
Subject local properties
Date Fri, 08 Oct 2004 09:36:47 GMT

I have had a proposal outstanding for a while for local properties:

I would like to see them included in ant.
There has been a (lot) of discussions - see

My current feelings (and implemenation) is

1) Syntax
The proposal adds a local property to a enclosing target/taskcontainer.

   <target name="example">
       <local name="prop" value="a local value"/>
       <echo>prop is ${prop}</echo>

   <macrodef name="t2">
       <attribute name="file"/>
         <local name="dir"/>
         <dirname property="dir" file="@{file}"/>
         <mkdir dir="${dir}"/>
         <touch file="@{file}"/>

I think it is nicer to do this rather that having an explicit local
property container, or having special elements for different types
of structures (like for example a <local> element at the same level
as <attribute> in a <macrodef>).

2) Shadowing of properties

The proposal allows local properties to shadow normal and user properties.
I feel that this is necessary to allow macrodefs to be written without
them failing sometimes. This means that the following will work:

  <import file="macros.xml"/>
  <property name="dir" value="."/>

  <t2 file="${user.home}/.ant/lib/js.jar"/>

ant -Ddir=/var/tmp

3) Extent of local properties

local properties will be inherited to child projects (if inheritall is 


Stephan Bodewig wrote:
> Things we need to consider IMHO:

> (1) Syntax

>Your proposal uses a <local> task that sets up a local scope for a
> named property until the enclosing target/sequential finishes.  Jose
> Alberto suggested to use a <local> TaskContainer instead, something
> like

> <local>
>  <local-property name="...."/>
> </local>

> which would essentially just add an explicit (and differently named)
> <seqential> to your proposal.  I think I prefer the more explicit,
> even if more verbose syntax of the second form.

> (2) Shadowing of properties

> Your updated proposal ensures that local properties do not override
> "global" user properties.  I think they shouldn't be allowed to
> override any outer scope properties at all.

> (3) Extent of local properties

> You make the local properties available to <script> - will they also
> be available for builds that get called with the <ant> family of tasks
> (assuming inheritall is true)?  I think they should be.

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

View raw message