ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knuplesch, Juergen" <>
Subject AW: clone fake environment variables as real ones for exec
Date Thu, 28 May 2009 08:23:58 GMT

One way this could work is by wrting your own exec2 task by using the <exec> source
and add an argument of your choice that does the trick (an extension of the env argument).

Probably a script (python, etc.) language is also able to set environment variables.
So you could use the script task.


Jürgen Knuplesch
-----Ursprüngliche Nachricht-----
Von: Shawn Castrianni [] 
Gesendet: Donnerstag, 28. Mai 2009 08:28
An: 'Ant Users List'
Betreff: clone fake environment variables as real ones for exec

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

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.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message