android: Bring back git hash version name

This commit is contained in:
SachinVin 2020-05-28 20:25:11 +05:30 committed by xperia64
parent 1eeff1097b
commit 29e5e6179c

View File

@ -33,6 +33,7 @@ android {
minSdkVersion 26
targetSdkVersion 28
versionCode autoVersion
versionName getVersion()
ndk.abiFilters abiFilter
}
@ -122,3 +123,17 @@ dependencies {
implementation 'com.android.billingclient:billing:2.2.0'
}
def getVersion() {
def versionName = '0.0'
try {
versionName = 'git describe --always --long'.execute([], project.rootDir).text
.trim()
.replaceAll(/(-0)?-[^-]+$/, "")
} catch (Exception e) {
logger.error('Cannot find git, defaulting to dummy version number')
}
return versionName
}