Skip to content

Instantly share code, notes, and snippets.

@azenla
Created July 30, 2013 22:50
Show Gist options
  • Save azenla/6117764 to your computer and use it in GitHub Desktop.
Save azenla/6117764 to your computer and use it in GitHub Desktop.
Minetweak Update Version Script
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