ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Sherbert" <sherb...@RigakuMSC.com>
Subject RE: Ant task needs optional override of properties
Date Mon, 14 Apr 2003 18:41:08 GMT
Yes your solution would work for me.  About your last statement:

> In the short term, you might want to patch <ant> to add an if/unless 
> attribute to nested <property> elements (CppTasks' elements all
support 
> it, and it's GREAT!), to be able to say:
>
> <ant dir="subproject" inheritall="false">
>   <property name="override.prop" value="${undefined}"
>             if="undefined" />
> </ant>

So you are saying CppTasks adds the if/unless attribute to the property
element of the ant task?

I tried to fetch CppTasks from sourceforge but had a few problems with
the build.  The cpptasks.jar file builds fine, but the documentation
targets break.  I believe I may be required to build Ant from scratch
instead of using a binary distributionn in order to get CppTasks to
build completely.  Is there any other online reference to the tasks and
properties available in CppTasks so I can continue working without
building the xdocs target?

Stephen Sherbert


-----Original Message-----
From: Dominique Devienne [mailto:DDevienne@lgc.com] 
Sent: Wednesday, April 09, 2003 6:21 PM
To: 'Ant Users List'
Subject: RE: Ant task needs optional override of properties


I understand exactly what you mean, as I'm currently faced with the
exact same problem. The way I'm going to solve it is by using
<propertyset> inside <ant>, or more exactly I'm going to enable the use
of <propertyset> inside my own copy of <subant>. That way, I'll be able
to say:

<!-- subant by default has inheritall="false" -->
<subant>
  <buildpath .../>
  <propertyset>
    <propertyref name="override.prop" />
  <propertyset>
</subant>

Only if override.prop is defined will it be passed down to the child/sub
build. Actually, the example above would be more equivalent to:

<ant dir="subproject" inheritall="false">
  <property name="override.prop" value="${override.prop}"/> </ant>

which is more my own problem. To solve yours using a <propertyset>, I'd
need something like:

<subant>
  <buildpath .../>
  <propertyset>
    <propertyref name="undefined" toname="override.prop" />
  <propertyset>
</subant>

which is kind of equivalent to what happens for references.

In the short term, you might want to patch <ant> to add an if/unless
attribute to nested <property> elements (CppTasks' elements all support
it, and it's GREAT!), to be able to say:

<ant dir="subproject" inheritall="false">
  <property name="override.prop" value="${undefined}"
            if="undefined" />
</ant>

Or did I not understand you? --DD

-----Original Message-----
From: Stephen Sherbert [mailto:sherbert@RigakuMSC.com] 
Sent: Wednesday, April 09, 2003 6:12 PM
To: Ant Users List
Subject: Ant task needs optional override of properties

<ant dir="subproject" inheritall="false">
  <property name="override.prop" value="${undefined}"/>
</ant>

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.

Stephen

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



Mime
View raw message