Skip to content

Instantly share code, notes, and snippets.

@stepango
Created December 4, 2014 13:33
Show Gist options
  • Save stepango/1b02cb2ec86747eb547a to your computer and use it in GitHub Desktop.
Save stepango/1b02cb2ec86747eb547a to your computer and use it in GitHub Desktop.
Version number using gradle and git
Integer getVersionCode() {
def sout = new StringBuffer()
def proc = 'git rev-list HEAD --count'.execute()
proc.consumeProcessOutput(sout, new StringBuffer())
proc.waitForOrKill(1000)
return sout.toInteger()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment