ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Drew Davidson <>
Subject Re: How can I have Ant replace unset properties as just empty string
Date Fri, 29 Mar 2002 22:23:48 GMT
Erik Hatcher wrote:

> ----- Original Message -----
> From: "Diane Holt" <>
> > foo could be set to "", so echoing ${foo} is the only way to truly show
> > it's not set at all.
> Well, since Diane likes to make sure we're all 100% accurate, I'll just
> provide a silly case that breaks this statement:
>     <property name="foo" value="$${foo}"/>
>     <echo>foo = ${foo}</echo>
> Anyway, as far as this issue goes, I'd be surprised if there was a really
> good reason why it returns "${foo}" if its not set - but in Ant 1.x we can't
> change it.  Ant2 - dunno how it works in myrmidon or mutant - but I suspect
> its different than this behavior.  It is very strange to get a ${build.dir}
> directory created.  Actually I think myrmidon throws an exception of the
> property isn't set but its referenced (?).

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

I'd like to be able to do the following:

<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"/>

<!-- Default appserver is Resin, as it should be -->
<property name="" value="resin"/>

<!-- Set rest of these properties from the appserver -->
<property name="appserver.root" value="${${}}.root}/>
<property name="appserver.webapps" value="${${}}.webapps}/>
--------------------- = resin
resin.version = 2.1.0

This is not the exact structure that I'd use for this because it's a trivial
example.  The point, however, is that I want to specify a single value
( in this case) that can then have other properties construct
property names and evaluate them (the ${${}} junk).  Hence
recusively defined variables.

Is this something that could happen in Ant2?  I'd be most appreciative as this
is one of gnumake's most valuable features for making flexible and dynamic
systems.  make also defines two classes of variables, the direct and the
recursively defined property.  I'm not sure that it's possible to do this in Ant
because the syntax would really stink.

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.

- Drew

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message