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

后端 未结 3 1346
孤街浪徒
孤街浪徒 2020-12-07 13:24

In several Tasks, I reference jars in my home folder.

Is there a better way to get Environment Variables than

ENV = System.getenv()
HOME = ENV[\'HOME         


        
相关标签:
3条回答
  • 2020-12-07 13:54

    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.

    0 讨论(0)
  • 2020-12-07 13:59

    In android gradle 0.4.0 you can just do:

    println System.env.HOME
    

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

    0 讨论(0)
  • 2020-12-07 14:01

    Well; this works as well:

    home = "$System.env.HOME"
    

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

    0 讨论(0)
提交回复
热议问题