ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erik Hatcher" <jakarta-...@ehatchersolutions.com>
Subject Re: How can I have Ant replace unset properties as just empty string
Date Sat, 30 Mar 2002 00:06:20 GMT
----- Original Message -----
From: "Drew Davidson" <drew@eblox.com>

> Do you think it would be a Good Thing to allow recursively defined
variables ala
> make?

I don't know, actually.  Seems powerful.  I can't think of any drawbacks to
allowing such things.  Will Ant2 handle this?  I don't know how the
proposals are dealing with these things at the moment - anyone care to
share?

But, there are alternatives already:

> I'd like to be able to do the following:
>
> build.xml:
> -----------
> <property name="resin.version" value="2.0.5"/>
> <property name="resin.root" value="/resin-cmp-${resin.version}"/>
> <property name="resin.webapps" value="${resin.root}/webapps"/>
>
> <property name="tomcat.version" value="4.0.1"/>
> <property name="tomcat.root" value="/tomcat-${tomcat.version}"/>
> <property name="tomcat.webapps" value="${tomcat.root}/webapps"/>

Alternative 1:

Split each app servers properties into a separate properties file -
resin.properties, tomcat.properties. Resin example:

appserver.root=<path to resin root>-${resin.version}
appserver.webapps=${appserver.root}/webapps

Then -

<property file="${appserver.name}.properties"/>

Alternative 2:

Take advantage of the 'id' attribute on <property>.  Here's an example, not
worked up in the same vein as Resin/Tomcat, so you'll have to use your
imagination.  This would get ugly probably as you'd have to duplicate things
for each property you wanted to "dereference", I think:

<property name="X" value="Y" id="X.prop"/>
<property name="Y" value="Z" id="Y.prop"/>
<property name="selector" value="${X}"/>
<property name="A" refid="${selector}.prop"/>
<echo message="A = ${A}"/>

Alternative 1 is pretty much the "Ant-way" for doing this kind of thing, and
the way I recommend.  What disadvantage does that approach have for you in
the kinds of scenarios you envision?  I'm quite curious to know where
Alternative 1 breaks down for any use-cases you have in mind.

> Also, as to the original thread, I think that the fact that a property is
> undefined should be usable (as it is currently with the if= and unless=)
and
> that the value should always expand to nothing when referenced.

That kind of change to expand to nothing will have to happen in Ant2 at the
very earliest simply because of the zillions of build files out there that
depend on Ant 1.x behavior remaining as-is.  Its a tough balancing act we
have to play with the 1.x codebase.  Perhaps we could make changes to break
backwards compatibility and hide them behind a switch that you'd have to
enable or something - food for thought at least.

    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