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" applicationId "com.pixelized.biblib"
minSdk 23 minSdk 23
targetSdk 30 targetSdk 30
versionCode 1 versionCode generateVersionCode()
versionName "0.1.2" versionName "0.1.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@ -106,3 +106,10 @@ dependencies {
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.0.0-beta06" 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()
}