Add dynamic version code.

This commit is contained in:
Thomas Andres Gomez 2021-05-09 12:03:00 +02:00
parent 9941777497
commit fa2af6dd90

View file

@ -12,7 +12,7 @@ android {
applicationId "com.pixelized.biblib"
minSdk 23
targetSdk 30
versionCode 1
versionCode generateVersionCode()
versionName "0.1.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@ -105,4 +105,11 @@ dependencies {
// Test
testImplementation 'junit:junit:4.13.2'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.0.0-beta06"
}
static def generateVersionCode() {
def result = "git rev-list HEAD --count".execute().text.trim() //unix
if (result.empty) result = "PowerShell -Command git rev-list HEAD --count".execute().text.trim() //windows
if (result.empty) throw new RuntimeException("Could not generate versioncode on this platform? Cmd output: ${result.text}")
return result.toInteger()
}