Skip to content

Instantly share code, notes, and snippets.

@azenla
Last active December 20, 2015 10:39
Show Gist options
  • Save azenla/6117765 to your computer and use it in GitHub Desktop.
Save azenla/6117765 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).parentFile.parentFile
def gradleScript = new File(mainDir, 'build.gradle')
def tmpFile = new File('build.gradle.tmp')
gradleScript.each {
if (it.startsWith('def version')) {
println 'Found Version: ' + evaluate(it)
it = 'def version = \'' + args[0] + '\''
}
tmpFile.append(it + '\n')
}
gradleScript.delete()
tmpFile.renameTo(gradleScript)
println('Set Version to ' + args[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment