The accepted answer works if you do not want to add properties to the project, since this is the first search result, I will add my solution, which works in gradle 3.x. An easy way to do this is through ant.
ant { property(file: 'properties.file') }
If you need to convert the property in Camel Case for easy access to your script (remember that the point-based syntax of the points and the actual object exist in gradle):
println "property value:{dot.property.from.file}" //this will fail. def camelCaseProperty = project.getProperties().get("dot.property.from.file") println "camelCaseProperty:${camelCaseProperty}" //this wont fail
If you need a default if not specified:
def propertyWithDefault = project.getProperties().get("dot.property.from.file","defaultValue");
Using this method, at least with IntelliJ / Android Studio, the IDE will link your properties file and gradle script and add completion, link checking, etc.
JDL Feb 10 '17 at 18:52 2017-02-10 18:52
source share