Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Gradle, is there a better way to get Environment Variables?

Tags:

gradle

Well; this works as well:

home = "$System.env.HOME"

It's not clear what you're aiming for.


I couldn't get the form suggested by @thoredge to work in Gradle 1.11, but this works for me:

home = System.getenv('HOME')

It helps to keep in mind that anything that works in pure Java will work in Gradle too.


In android gradle 0.4.0 you can just do:

println System.env.HOME

classpath com.android.tools.build:gradle-experimental:0.4.0


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!