在Gradle中,有没有更好的方式来获取环境变量? [英] In Gradle, is there a better way to get Environment Variables?

查看:507
本文介绍了在Gradle中,有没有更好的方式来获取环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



有没有比获得环境变量更好的方法

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

任务copyToServer(dependsOn:'jar',类型:复制){
$ b $从'build / libs /'
到HOME +/ something / plugins /
}

这设定了$ HOME,但我希望我错过了文档中的一些魔法。

解决方案

这也适用:

  home =$ System.env.HOME

目标不明确。

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']

task copyToServer(dependsOn: 'jar', type: Copy) {

 from 'build/libs/'
 into HOME + "/something/plugins/"
}

This sets $HOME but I was hoping that I missed some magic from the documentation.

解决方案

Well; this works as well:

home = "$System.env.HOME"

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

这篇关于在Gradle中,有没有更好的方式来获取环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆