How to have a Gradle task set shell set environment variables?


(Ganesh) #1

I have a Gradle task which invokes a shell script which sets some environment variables. These variables are used by another shell script which is also invoked by Gradle as another task. However, the second task cannot view these variables. What is wrong and how do I actually achieve my required behavior?

I am working in Unix/Linux. Both the Gradle tasks are basically Exec type of tasks.


(Adrian Lis) #2

I know its an old question but I have the same problem.

I have a 3rd party tool that has a shell script setting up an environment for the build commands to work and I run the shell script as Exec type in one task and need to run custom build task in another that depends on the shell environment to be preconfigured by the shell script.

The problem is that the Exec tasks spawns a new process so the shell environment is set for the duration of the exec command so when it comes down to build the environment is gone.

Any ideas how to properly resolve such issue?