Thanks to Groovy MOP capabilities we can create flexible and readable code. Last time I created PropertyReader class inspired by MarkupBuilder and XmlSlurper. This class allows to read and write from/to properties files. Data in that file is store in key=value notation.
Usage
Here is the example of gradle.properties file:
To read the property just call propertyReader.'yourProperty'. And to update or write new property call propertyReader.'yourPropertyKey'('yourPropertyValue'). Here is the example of usage of PropertyReader class:
Result
After running the above script and refreshing c:/gradle.properties file it should contain similar content: