Forked from pratul/android-versioncode-git-describe.gradle
Created
March 1, 2017 06:14
-
-
Save engincancan/115d45726e66a8dccdb36e8d1cd5706d to your computer and use it in GitHub Desktop.
A gradle method to generate Android versionCode using git describe.
This file contains hidden or 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
def getVersionCode = { -> | |
try { | |
def stdout = new ByteArrayOutputStream() | |
exec { | |
commandLine 'git', 'rev-list', '--first-parent', '--count', 'origin/master' | |
standardOutput = stdout | |
} | |
return Integer.parseInt(stdout.toString().trim()) * 100 | |
} | |
catch (ignored) { | |
return -1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment