Gradle - 包含属性文件 [英] Gradle - Include Properties File

查看:110
本文介绍了Gradle - 包含属性文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Gradle中包含属性文件?



例如在Ant中,我可以执行以下操作:

 < property file =$ {basedir} /build.properties/> 


解决方案

您可以使用java语法来完成它,例如:

 属性props = new Properties()
InputStream in = new FileInputStream(/ path / file.properties)
props.load(in)
in.close()

这应该在任何时髦的脚本中工作。可能还有一种更常规的方式,使用闭包或其他一些奇特的快捷方式。


How would I include a properties file in Gradle?

For example in Ant, I could do the following:

<property file="${basedir}/build.properties" />

解决方案

You could do it using the java syntax, e.g.:

Properties props = new Properties()
InputStream in = new FileInputStream("/path/file.properties")
props.load(in)
in.close()

This should work in any groovy script. There might be a more "groovy" way of doing it though, using closures or some other fancy shortcut.

这篇关于Gradle - 包含属性文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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