Update change-version.py to handle build.gradle, and clean it up

This commit is contained in:
Manu Sridharan 2018-08-22 09:51:54 -07:00
parent c40c7e34f0
commit 5d7b4d5988
1 changed files with 9 additions and 10 deletions

View File

@ -5,6 +5,10 @@
import sys
import subprocess
def runAndPrint(cmd):
print cmd
subprocess.check_output(cmd, shell=True)
oldVersion = sys.argv[1]
newVersion = sys.argv[2]
@ -13,13 +17,11 @@ print oldVersion + " --> " + newVersion
oldVersion = oldVersion.replace(".", "\.")
newVersion = newVersion.replace(".", "\.")
cleanCmd = "mvn clean -q"
print cleanCmd
subprocess.check_output(cleanCmd, shell=True)
runAndPrint("mvn clean -q")
xmlCmd = "find -E ./ -regex \".*(pom|mvncentral)\.xml\" | xargs -n 1 perl -pi -e \'s/" + oldVersion + "/" + newVersion + "/g\'"
print xmlCmd
subprocess.check_output(xmlCmd, shell=True)
runAndPrint("find -E ./ -regex \".*(pom|mvncentral)\.xml\" | xargs -n 1 perl -pi -e \'s/" + oldVersion + "/" + newVersion + "/g\'")
runAndPrint("perl -pi -e \'s/" + oldVersion + "/" + newVersion + "/g\' build.gradle")
oldIsSnapshot = oldVersion.endswith("SNAPSHOT")
newIsSnapShot = newVersion.endswith("SNAPSHOT")
@ -27,10 +29,7 @@ newIsSnapShot = newVersion.endswith("SNAPSHOT")
bundleOld = oldVersion if not oldIsSnapshot else oldVersion.replace("-SNAPSHOT","\.qualifier")
bundleNew = newVersion if not newIsSnapShot else newVersion.replace("-SNAPSHOT","\.qualifier")
otherCmd = "find -E ./ -regex \".*(MANIFEST\.MF|feature\.xml)\" | xargs -n 1 perl -pi -e \'s/" + bundleOld + "/" + bundleNew + "/g\'"
print otherCmd
subprocess.check_output(otherCmd, shell=True)
runAndPrint("find -E ./ -regex \".*(MANIFEST\.MF|feature\.xml)\" | xargs -n 1 perl -pi -e \'s/" + bundleOld + "/" + bundleNew + "/g\'")
print "done"