Replace parent versions recursively in poms

import groovy.io.FileType

List listOfPomFiles = []
String newVersion = args[0] 

new File('.').eachFileRecurse(FileType.FILES) {
    if(it.name.equals('pom.xml')) {
        listOfPomFiles.add(it)
    }
}

println "\nfound following pom.xmls in current directory:"
listOfPomFiles.eachWithIndex { it, i -> // `it` is the current element, while `i` is the index
    println "$i: $it"
}

println "\n started processing of pom.xml files";
// iterate through found poms and replace the parent's version content
listOfPomFiles.each{
    File pomFile = it
    println "processing $pomFile";
	
	Node project = new XmlParser().parse(pomFile)

	println "old version: " + project.parent.version.text()
	// update with new version
	project.parent.version[0].replaceNode{
		version(newVersion)
	}
		
	// print to file
	FileWriter fileWriter = new FileWriter(pomFile) 
	XmlNodePrinter printer = new XmlNodePrinter(new PrintWriter(fileWriter))
	printer.setPreserveWhitespace(true)
	printer.print(project)


	// print to console
	// XmlNodePrinter printer = new XmlNodePrinter()
	// printer.setPreserveWhitespace(true)
	// printer.print(project)

	println "new version: " + project.parent.version.text()
}

println "\nfinished processing of pom.xml files";