ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Castrianni <>
Subject clone fake environment variables as real ones for exec
Date Thu, 28 May 2009 06:27:38 GMT
I load in my environment variables with:

<property environment="env"/>

I use ant properties throughout my script with the env. prefix so that end users can override
them with real environment variables, if they wish.  If those env. prefixed ant properties
are not initialized from the real environment variables, I default them inside ant.  This
results in fake environment variables that are really just ant properties with an env. prefix.

My problem is if I call an exec task, I would like to pass in all the fake env. variables
into that exec task.  Any real environment variables get automatically passed down or inherited
by the exec task, so those work fine.  However, the fake env. prefixed ant properties that
were not initialized from the real environment and defaulted within ant are not passed down
because they are only ant properties.  I would rather not have to specify lots of <env>
tags within my exec call just to translate my fake env. prefixed ant properties into real
environment variables for the duration of the exec call.  Something like:

<exec executable="whatever" dir="whatever">
                <env key="ENV1" value="${env.ENV1}"/>
                <env key="ENV2" value="${env.ENV2}"/>
                <env key="ENV3" value="${env.ENV3}"/>

I would prefer to somehow tell ant to select all properties that start with env. prefix and
add them to the environment of the exec task.  Is this possible somehow with macros, property
selectors, or something else?

Shawn Castrianni

This e-mail, including any attached files, may contain confidential and privileged information
for the sole use of the intended recipient.  Any review, use, distribution, or disclosure
by others is strictly prohibited.  If you are not the intended recipient (or authorized to
receive information for the intended recipient), please contact the sender by reply e-mail
and delete all copies of this message.

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