ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erik Hatcher" <jakarta-...@ehatchersolutions.com>
Subject Re: Scope of a property
Date Thu, 29 Nov 2001 02:26:42 GMT
> I want to discuss a little bit more on this.

A topic dear to my heart....

> >From what I understand, a property within a target will not be available
to
> another target unless there is a dependence.

Well, sort of.  For the same execution thread (terminology is a bit off
here) properties are available any time after being defined.

> For example,
>
> <target name="myInit">
> <property name="Me" value="IsMe"/>
> </target>
>
> <target name="showMe">
> <echo message="${Me}"/>
> </target>
>
> the above echo will not display any.
>

These two targets are never executed at the same time.  You'd run these by
doing one of:

    ant myInit showMe

-or-

    ant myInit
    ant showMe

Both are essentially equivalent and each invocation starts fresh with
properties.

> However, the following will work
> <target name="showMe" depends="myInit">
> <echo message="${Me}"/>
> </target>
>
>
> But anyway, in order to make a property global, you have to put it outside
> targets.
> Am I right?

Again, you're right in that this is typically how it would work, but other
scenarios exist using <ant>/<antcall> so that a property defined can be
overridden or set for the invocation.

Clear as mud?!  :)

    Erik



--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message