ant-dev mailing list archives

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

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

http://issues.apache.org/bugzilla/show_bug.cgi?id=23942

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

http://marc.theaimsgroup.com/?t=108765926600001&r=1&w=2
http://marc.theaimsgroup.com/?t=107030281800001&r=1&w=2
http://marc.theaimsgroup.com/?t=106916956400008&r=1&w=2

My current feelings (and implemenation) is

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

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

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

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:

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

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

ant -Ddir=/var/tmp

3) Extent of local properties

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

Peter

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: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message