ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <>
Subject Re: <property file="..." prefix="..."/> what to expand?
Date Mon, 21 Jun 2010 07:09:59 GMT
On 2010-06-18, Dominique Devienne wrote:

> On Fri, Jun 18, 2010 at 2:47 AM, Stefan Bodewig <> wrote:
>> On 06/17/2010 11:10 AM, Stefan Bodewig wrote:
>> Assume

>> x=x
>> y=${x}

>> and that there is no property x defined prior to

>>    <property file="..."/>

>> then ${y} will be "x".  Using

>>    <property file="..." prefix="foo"/>

>> ${foo.y} in Ant 1.8.0 is ${x} while it is "x" in 1.8.1 - the properties
>> file was able to refer to its own properties without knowledge of the
>> prefix.

> This feels "natural" to me, and ${foo.y}'s value being "${x}"
> surprising indeed.  But conversely, if property x is already defined,
> I'd expect that value to prevail, according to classic immutability
> rules.  Yet as you point out we can't have both behaviors at the same
> time if I understand correctly.

${x} wins over ${foo.x} is the behavior we used to have - and what the
bugzilla report wants back.  It's not what loadproperties does, though.
The question is whether we want the tasks to be consistent and if so,
what we want them to do.

It comes down to what the writer of the property file intended.  If I
want my property file to be self-contained, then I want Ant to rewrite
the references.  As soon as Ant does that I either lose access to
properties defined outside the file (the canonical ${build.dir} example)
or we get a more complex logic of "is the property defined outside the
file, use the outside value, otherwise use the one inside - which I have
working locally.

<loadproperties> makes that choice explicit right now.  If I want my
file to be self-contained, I use the prefix attribute and all expansions
will be rewritten by Ant.  If I don't want this to happen, I don't use
the prefix attribute but a a prefixlines filter to my filterchain which
just adds the prefix to each newly defined property.

Not that this effect was documented anywhere 8-)

> Can't property expansion in a property file be done "entirely" before
> the prefix is applied?

Not without breaking property immutability in specific cases.

> Another impractical idea quite likely, but what about a ${.:x}
> notation, to force the expansion of propery x to point to the "local"
> context, taking the prefix into account?

Could work.


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

View raw message