Setting environment variables in gradle


(Erik Sapir) #1

Is there a way to set environment variables in gradle?

I use the tomcat plugin to start Tomcat from a war i built. I need to set some environment variables before the server is starting. How i can i do that?


(Peter Niederwieser) #2

From what I can see in the Gradle Tomcat plugin docs, the plugin runs Tomcat in the Gradle process, in which case you can set environment variables via ‘GRADLE_OPTS’. Alternatively, you might want to look into the Gradle Cargo or Gradle Arquillian plugin, which can also run containers in an external process.


(Erik Sapir) #3

What is exactly GRADLE_OPTS? How i use it to set my own environment variable?


(Peter Niederwieser) #4

Sorry, I mixed this up. Environment variables for the Gradle process can only be set from outside Gradle, in a manner that’s appropriate for your environment/OS.