Gradle - Include Properties File

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"


I would actually recommend using Gradle's default properties file. If you put the properties in gradle.properties in the same directory as the build.gradle, they will automatically be available.

See the user guide.

Tags:

Gradle