I have a gradle task to read a properties file and modify one of the property.
task addVersion {
File configPropFile = file(configFilePath)
def configProperties = new Properties()
configProperties.load(configPropFile.newDataInputStream())
def versions = configProperties.getProperty('product.versions')
if(!versions.contains("1.2")){
configProperties.setProperty('product.versions', versions + ',' + "1.2")
}
configProperties.store(configPropFile.newWriter(), null)
}
This task successfully rewrites the properties file, but while rewriting it doesn't maintains the sequence in which the properties were read. Can someone help me out with the changes I need to make to maintain the sequence of the properties in the file?