You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Paul Philion <ph...@acmerocket.com> on 2000/07/25 17:44:45 UTC

Some thoughts about runtime evaluation of properties

Greetings -

I would really prefer to see properties, including ${}, get evaluated
at runtime. I've been thinking about how that could be done.

- All properties are handled by Project, including any immutability,
etc.

- The Property task will simply setProperty on the Project. An
exception could be thrown, or the new property value could just be
ignored (Project will log it).

- A PropertySheet (or something like that) will handle storing the
properties. It will parse the ${} values and store special referring
properties that will not be evaluated until each getProperty request.

For example:
    <property name="lib.dir" value="${build.dir}/lib"/>

This will be stored (under the key "lib.dir") as a special object that
contain the "unresolved property" (build.dir) and the appended value
"/lib".

When code requests project.getProperty("lib.dir"), the PropertySheet
recognizes that the property is an unresolved (complex? dependant?)
property and does the immediate substitution before returning the
property.

- Paul


Re: Some thoughts about runtime evaluation of properties

Posted by James Duncan Davidson <du...@x180.com>.
on 7/26/00 1:20 PM, Ken Liu at kliu@auctionlogic.com wrote:

> That's an interesting point that you subtly make.  A <property> looks like a
> task and feels like a task, but it really isn't one.  The <property> "task"
> is the only task that changes the state of the ant system, right?  That may
> (or may not) be confusing to a user...

Why sound it feel like a task -- it should be one level higher than a task.

<project>
  <help/> (!)
  <property/>
  <property/>
  <target>
    <task/>
    <task/>
  </target>
</project>

> 
> Ken
> 
> 
>> had a fixed value, constructed from the value build.dir had when this
>> task (if you want to call <property> a task) was executed.
>> 
>> Stefan
>> 
> 


RE: Some thoughts about runtime evaluation of properties

Posted by Ken Liu <kl...@auctionlogic.com>.
That's an interesting point that you subtly make.  A <property> looks like a
task and feels like a task, but it really isn't one.  The <property> "task"
is the only task that changes the state of the ant system, right?  That may
(or may not) be confusing to a user...

Ken


> had a fixed value, constructed from the value build.dir had when this
> task (if you want to call <property> a task) was executed.
>
> Stefan
>


Re: Some thoughts about runtime evaluation of properties

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "PP" == Paul Philion <ph...@acmerocket.com> writes:

 PP> Note: I'm not suggesting that that is something that should be
 PP> supported, or that it is something anyone would ever use. I'm
 PP> just trying to point out potential issues.

I'm aware of the limitation my approach imposes - and didn't want to
say yours would be unreasonable. 

I was just thinking loud to see which way would be the preferred one -
as we seem to agree to move to runtime evaluation.

Stefan

Re: Some thoughts about runtime evaluation of properties

Posted by Roger Vaughn <rv...@seaconinc.com>.
Paul Philion wrote:

> Stefan -
>
> That's a reasonable way to do it (and easy to implement), unless
> someone wants to implement something like:
>
> <property name="dist.bin.dir" value="${dist.dir}/bin"/>
> <property name="dist.lib.dir" value="${dist.dir}/lib"/>
> ...
> <target xyz...>
>     <property name="dist.dir" value="../package1/dist"/>
> </target>
> <target zyx...>
>     <property name="dist.dir" value="../package2/dist"/>
> </target>
>
> Note: I'm not suggesting that that is something that should be
> supported, or that it is something anyone would ever use. I'm just
> trying to point out potential issues.
>
> My goal is to make ant build files as simple as possible, both the
> write and understand. Immutable properties are very attractive (for
> their simplicity) but they do produce problems.
>
> - Paul

Paul,

This is *exactly* what I did in some earlier projects.  It worked in
1.0.8, but broke when properties became immutable in 1.1, which
eventually accounted for a huge flood of messages.....  I happen to like
the pattern myself.

roger



RE: Some thoughts about runtime evaluation of properties

Posted by Paul Philion <ph...@acmerocket.com>.
Stefan -

That's a reasonable way to do it (and easy to implement), unless
someone wants to implement something like:

<property name="dist.bin.dir" value="${dist.dir}/bin"/>
<property name="dist.lib.dir" value="${dist.dir}/lib"/>
...
<target xyz...>
    <property name="dist.dir" value="../package1/dist"/>
</target>
<target zyx...>
    <property name="dist.dir" value="../package2/dist"/>
</target>

Note: I'm not suggesting that that is something that should be
supported, or that it is something anyone would ever use. I'm just
trying to point out potential issues.

My goal is to make ant build files as simple as possible, both the
write and understand. Immutable properties are very attractive (for
their simplicity) but they do produce problems.

- Paul

> -----Original Message-----
> From: Stefan Bodewig [mailto:bodewig@bost.de]
>
> This would also mean
>
> <property name="lib.dir" value="${build.dir}/lib"/>
>
> had a fixed value, constructed from the value build.dir had
> when this
> task (if you want to call <property> a task) was executed.


Re: Some thoughts about runtime evaluation of properties

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "PP" == Paul Philion <ph...@acmerocket.com> writes:

 PP> I would really prefer to see properties, including ${}, get
 PP> evaluated at runtime.

Guess we are close to starting a vote on this.

 PP> When code requests project.getProperty("lib.dir"), the
 PP> PropertySheet recognizes that the property is an unresolved
 PP> (complex? dependant?)  property and does the immediate
 PP> substitution before returning the property.

I didn't go that far in my line of thought. I was thinking of delaying
${} expansion to the point where the task in question was going to be
executed, basically storing the AttributeSet from the build file
together with the task in target and call ProjectHelper.configure
on the task right before Task.execute is called.

This would also mean

<property name="lib.dir" value="${build.dir}/lib"/>

had a fixed value, constructed from the value build.dir had when this
task (if you want to call <property> a task) was executed. 

Stefan