Created
July 30, 2013 22:50
-
-
Save azenla/6117764 to your computer and use it in GitHub Desktop.
Minetweak Update Version Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!args.size()==1) {println('Usage: updateVersion.groovy New.Version') ; return} | |
def mainDir = new File(getClass().protectionDomain.codeSource.location.path).getParentFile().getParentFile() | |
def newVersion = args[0] | |
def gradleScript = new File(mainDir, 'build.gradle') | |
def input = gradleScript.newReader() | |
def tmpFile = new File('build.gradle.tmp') | |
def output = new FileWriter(tmpFile) | |
input.eachLine { | |
if (it.startsWith('def version')) { | |
println 'Found Version: ' + evaluate(it) | |
it = 'def version = \'' + newVersion + '\'' | |
} | |
output.write(it + '\n') | |
} | |
output.flush() | |
output.close() | |
input.close() | |
gradleScript.delete() | |
tmpFile.renameTo(gradleScript) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment