ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Reilly" <peter.kitt.rei...@gmail.com>
Subject Re: Local Properties
Date Tue, 28 Aug 2007 08:34:47 GMT
On 8/28/07, Stefan Bodewig <bodewig@apache.org> wrote:
> On Mon, 27 Aug 2007, Peter Reilly <peter.kitt.reilly@gmail.com> wrote:
> > On 8/27/07, Stefan Bodewig <bodewig@apache.org> wrote:
>
> >> How does nesting of locals work?  If a macro calls another macro,
> >> are the properties set in the outer macro available to the inner?
> >> What about <ant> subbuilds invoked from inside a macro?
> >
> > Nesting works for calling other macros (otherwise ant-contrib for
> > would not work too good!).
>
> OK.
>
> > But not for calling ant subbuilds invoked from inside a macro.
> > The reasoning here is that 1) the code is awful (and thus hard to
> > maintain) and 2) it is not necessary as one can use nested
> > <property> tags on the <ant> task and 3) it may be confusing (where
> > do these fit with nested property, user and non-user properties).
>
> 2) implies that I'm aware there is a local property around.  I know I
> am probably constructing something unlikely to happen, but I'm trying
> to understand what would happen before I dive into the code.
>
> Given
>
> <target name="echo">
>   <echo>In antcall: ${foo}</echo>
> </target>
>
> <macrodef name="inner">
>   <sequential>
>     <echo>In inner: ${foo}</echo>
>     <antcall target="echo"/>
>   </sequential>
> </macrodef>
>
> <macrodef name="outer">
>   <sequential>
>     <make a local property "foo" and set it to "baz"/>
>     <inner/>
>   </sequential>
> </macrodef>
>
> <target name="callWithMacro">
>   <property name="foo" value="bar"/>
>   <outer/>
> </target>
>
> would result in
>
> In inner: baz
> In antcall: bar
>
> Correct?

Yes:
callWithMacro:
     [echo] In inner: baz

echo:
     [echo] In antcall: bar

>
> By just looking at inner and not at the path it gets called you can't
> know that a local property exists.
>
> I don't say this is a big problem, but I can see how it is going to
> confuse people.  At least we need to document it properly - or find a
> non-awful way to make it work 8-)

Everything to do with <antcall>, <ant>, <subant> etc is a nightmare, I would
rather deprecate the whole lot and replace them with  macros (antcall) or
with calls to a new jvm (for <subant>).

In any case, if local properties are to be inherited, the properties defined
in the <property> element of the <ant> task would have to take precedence
over the inherited local-properties.

Peter


>
> >> I think there are two options: restricting it to sequential or
> >> allowing it for any TaskContainer.
> >
> > This is hard as the TaskContainer user implementation controls when
> > the sequence of UEs are to be invoked (or reinvoked) and there is no
> > hook back to ant core as to when this happens.
>
> OK, so I really need to read the code before I comment any further.
>
> Stefan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
>

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


Mime
View raw message