How can I pass a properties file on the command line, have a task read it and have all tasks uses the properties?


(J.V.) #1

I want to pass a .properties file to gradle (on the command line: -Pproperties=my.properties) and have a gradle task read it and make those properties available to all tasks (and other config / closure sections),

Is this possible? I have been able to provide individual properties on the command line but I want to send it a file, have gradle read it and use properties across multiple tasks.


(Peter Niederwieser) #2

This would need some standard Java/Groovy coding to read the properties file (using the ‘java.lang.Properties’ class), which you could then make available via a Gradle extra property (e.g. ‘ext.configSettings = myProperties’).