forked from StripesFramework/stripes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbump-version.groovy
executable file
·34 lines (30 loc) · 995 Bytes
/
bump-version.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env groovy
if (args.length<2) {
println "Usage :"
println "./bump-version.groovy oldVersion newVersion"
return
}
def oldVersion = args[0]
def newVersion = args[1]
// handle all POMs
println "Handling all pom.xml files..."
int nbPoms = 0
new File(".").eachFileRecurse { File f ->
if (!f.directory && !f.absolutePath.contains("target") && f.name == "pom.xml") {
println "replacing in $f.absolutePath..."
// replace version in pom
String pomText = f.text
int nbReplaces = 0
while (pomText.contains(oldVersion)) {
pomText = pomText.replaceFirst(oldVersion,newVersion)
nbReplaces++
}
assert "invalid number of replacements in $f.absolutePath", nbReplaces == 1
f.text = pomText
println "... done with $f.absolutePath"
nbPoms++
}
}
assert nbPoms == 5
println "Replaced versions in $nbPoms pom files"
println "Done. Version bumped from $oldVersion to $newVersion"