I would like to control the “global” configuration in Gradle build scripts using the external properties files on each build machine (dev, ci, uat, ...) and specify the file name with a command line argument.
eg. gradle -DbuildProperties=/example/config/build.properties
I specifically do not want to use gradle.properties, since we have existing projects that already use this approach, and (for example) we want to be able to change the database URLs and jdbc drivers without changing each project.
So far have tried: -
Properties props = new Properties()
props.load(new FileInputStream("$filename"))
project.setProperty('props', props)
which works but has an outdated warning, but I cannot figure out how to avoid this.
Also tried using groovy style configuration files with ConfigSlurper: -
environments {
dev {
db.security {
driver=net.sourceforge.jtds.jdbc.Driver
url=jdbc:someserver://somehost:1234/some_db
username=userId
password=secret
}
}
}
but colons and slashes cause exceptions, and we don’t want to spoil the config with escape characters.
- - "" ?