Gradle - Include Properties File

前端 未结 9 1018
天命终不由人
天命终不由人 2020-12-08 04:13

How would I include a properties file in Gradle?

For example in Ant, I could do the following:



        
9条回答
  •  有刺的猬
    2020-12-08 04:35

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

    Properties props = new Properties()
    InputStream ins = new FileInputStream("/path/file.properties")
    props.load(ins)
    ins.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.

    EDIT: "in" is a reserved word in groovy. A variable can't be named that way, renaming it to "ins"

提交回复
热议问题