Changed how versionCode is set

This commit is contained in:
Sylvain Berfini 2021-11-23 14:23:27 +01:00
parent 47984597af
commit d3b3400688

View file

@ -5,6 +5,11 @@ plugins {
id 'org.jlleitschuh.gradle.ktlint' id 'org.jlleitschuh.gradle.ktlint'
} }
def appVersionName = "4.6.0"
// Uncomment for release
// def appVersionCode = 40600 // 4.06.00
def appVersionCode = 40590 // 4.05.90
static def getPackageName() { static def getPackageName() {
return "org.linphone" return "org.linphone"
} }
@ -24,7 +29,7 @@ if (crashlyticsEnabled) {
def gitBranch = new ByteArrayOutputStream() def gitBranch = new ByteArrayOutputStream()
task getGitVersion() { task getGitVersion() {
def gitVersion = "4.6.0" def gitVersion = appVersionName
def gitVersionStream = new ByteArrayOutputStream() def gitVersionStream = new ByteArrayOutputStream()
def gitCommitsCount = new ByteArrayOutputStream() def gitCommitsCount = new ByteArrayOutputStream()
def gitCommitHash = new ByteArrayOutputStream() def gitCommitHash = new ByteArrayOutputStream()
@ -52,9 +57,9 @@ task getGitVersion() {
} else { } else {
gitVersion = gitVersionStream.toString().trim() + "." + gitCommitsCount.toString().trim() + "+" + gitCommitHash.toString().trim() gitVersion = gitVersionStream.toString().trim() + "." + gitCommitsCount.toString().trim() + "+" + gitCommitHash.toString().trim()
} }
println("Git version: " + gitVersion) println("Git version: " + gitVersion + " (" + appVersionCode + ")")
} catch (ignored) { } catch (ignored) {
println("Git not found") println("Git not found, using " + gitVersion + " (" + appVersionCode + ")")
} }
project.version = gitVersion project.version = gitVersion
} }
@ -84,7 +89,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 23 minSdkVersion 23
targetSdkVersion 31 targetSdkVersion 31
versionCode 4600 versionCode appVersionCode
versionName "${project.version}" versionName "${project.version}"
applicationId getPackageName() applicationId getPackageName()
} }