I wrote a task in gradle that grabs an environment variable.
task run(type:Exec) {
    def SYS_ENV = System.getenv("SYSTEM_ENV")
    // do something with SYS_ENV 
}
If I run this task with ./gradlew :taskName it's all fine, but if I run the same task from IntelliJ IDEA, (with the  button, or from the gradle panel) the env variable comes out as
 button, or from the gradle panel) the env variable comes out as null.
I tried restarting IntelliJ, I also tried the Invalidate Caches/Restart option, but nothing changes.
Isn't IntelliJ IDEA supposed to run the Gradle script exactly like I run it form the command? What can I do to grab an env variable from Grade so that the script doesn't fail when run form IntelliJ?
EDIT: I did a bunch of trials, and I could make lanchctl setenv MY_PATH MY_VALUE work, but it's not permanent, and adding setenv MY_PATH MY_VALUE to /etc/lanchd.conf does not make it so.
 
     
    