in script/version/UpdateDepsVersionKamelets.groovy [26:64]
def updateKameletDirectory(String directoryName, Map properties) {
println "#### Update Dependencies Version Kamelets BEGIN"
// compute version replacement
def libVersions = [:]
properties.each {prop ->
if (prop.key.startsWith("version.")) {
String ga = prop.key.substring("version.".length())
int split = ga.lastIndexOf(".")
if (split > 0 && split < ga.length() - 1) {
String groupId = ga.substring(0, split)
String artifactId = ga.substring(split + 1)
String libSelector = "mvn:" + Pattern.quote(groupId) + ":" + Pattern.quote(artifactId) + ":[A-Za-z0-9-.]+"
String libNewVersion = "mvn:" + groupId + ":" + artifactId + ":" + prop.value
libVersions[libSelector] = libNewVersion
println "#### Going to replace in all files \"${libSelector}\" with \"${libNewVersion}\""
}
}
}
File directory = new File(directoryName)
File[] files = directory.listFiles()
for (File f in files) {
if (f.getName().endsWith(".kamelet.yaml")) {
String kameletFile = f.getName()
new File( kameletFile + ".bak" ).withWriter { w ->
new File( directoryName + kameletFile ).eachLine { line ->
libVersions.each { line = line.replaceAll(it.key, it.value) }
w << line + System.getProperty("line.separator")
}
}
Files.copy(Paths.get(kameletFile + ".bak"), Paths.get(directoryName + kameletFile), StandardCopyOption.REPLACE_EXISTING)
boolean deleted = new File(kameletFile + ".bak").delete()
}
}
println "#### Update Dependencies Version Kamelets END"
}