ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <>
Subject Re: Q: Nasty environment variable behavior?
Date Fri, 20 Jul 2001 05:47:33 GMT
On Thu, 19 Jul 2001, Steve Nesbitt <> wrote:

>     <property name="build.type" value="${env.BUILD_TYPE}" />
> The nasty behavior I'm experiencing is that if an environment
> variable is not defined, then the value of the property is not left
> undefined but set to the string in the value field.

This is expected behavior (count that as confirming your observation 8-).

All ${} expansions in Ant work that way, i.e. they resolve to the
value of the referenced property or don't change the whole ${}
expression at all.  Historically this is the behavior we need to allow
properties in files loaded via the file attribute of the property task
to reference other properties defined in the same file.  This behavior
is probably not going to change in the Ant 1.x series.

Apart from falling back to native scripts or script tasks, a
workaround would be something like

<target name="init-build-type" if="env.BUILD_TYPE">
  <property name="build.type" value="${env.BUILD_TYPE}" />

which may become nasty if you have more than one environment variable
to translate.


View raw message