I need to execute from Gradle an Ant script which relies on environment variables. Ant uses
<property environment="env"/>
for it.
I tried to do
env.foo="bar"
in Gradle, but it throws a Groovy exception.
What is the proper way to pass environment variables from Gradle to Ant?
Gradle, and more generally the JDK, doesn’t support setting environment variables from inside the process. I’d consider tweaking the Ant script, calling Ant as an external process (e.g. via JavaExec), or setting the environment variable externally.
You could fake it, by doing something like:
ant.properties['env.foo'] = 'bar'
Thanks a lot!
That’s exactly what I was searching for.