ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Sherbert" <>
Subject Ant task needs optional override of properties
Date Wed, 09 Apr 2003 23:11:43 GMT
<ant dir="subproject" inheritall="false">
  <property name="override.prop" value="${undefined}"/>

In the above case, I need to override a property in the sub project's
build file.  This is standard practice in the world of Ant.  Properties
are immutable and therefore do not get defined until set, after which
they cannot change.

However let's say that the property "undefined" has not been set at the
time this ant task is executed.  When properties are not defined what
happens?  Well Ant replaces them with their substitution string, in this
case "${undefined}".  This is usually a good indication that you tried
to use a property before assigning it a value.

I don't really think this should change, but there needs to be a way to
optionally override a property in an ant task, just like if I had set
inheritall="true", but for individual properties.  If I did not
explicitly spell out which properties to override and used
inheritall="true" then only the properties that have been set would be
passed to the sub project's build file.  It would not pass in build.dir
= "${build.dir}" heaven forbid!

Is it possible to have the ant task inspect the value of the overriden
property and not set it's value in the sub project's build file if it
matches "${.*}"?  It seems to me that this is the way the ant task
should handle things, but alas it does not.

I'm afraid my words may not convey my meaning too well, but in my mind
it is crystal clear that it does not work right and there should at
least be a means to accomplish this task without resorting to
<if>/<else> tasks or using <property file="...">.  There should be a way
to emulate how properties are usually handled with respect to setting a
property if you have a value for it or holding off until you do.


View raw message