fix: versionCode increment
This commit is contained in:
parent
34066ea182
commit
9895ed1061
|
@ -10,6 +10,13 @@ plugins {
|
||||||
alias(libs.plugins.grgit)
|
alias(libs.plugins.grgit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val versionFile = file("$rootDir/versionCode.txt")
|
||||||
|
val versionCodeIncrement = if (versionFile.exists()) {
|
||||||
|
versionFile.readText().toInt() + 1
|
||||||
|
} else {
|
||||||
|
1
|
||||||
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = Constants.APP_ID
|
namespace = Constants.APP_ID
|
||||||
compileSdk = Constants.TARGET_SDK
|
compileSdk = Constants.TARGET_SDK
|
||||||
|
@ -22,7 +29,7 @@ android {
|
||||||
applicationId = Constants.APP_ID
|
applicationId = Constants.APP_ID
|
||||||
minSdk = Constants.MIN_SDK
|
minSdk = Constants.MIN_SDK
|
||||||
targetSdk = Constants.TARGET_SDK
|
targetSdk = Constants.TARGET_SDK
|
||||||
versionCode = Constants.VERSION_CODE + (versionCode ?: 0)
|
versionCode = Constants.VERSION_CODE + versionCodeIncrement
|
||||||
versionName = determineVersionName()
|
versionName = determineVersionName()
|
||||||
|
|
||||||
ksp { arg("room.schemaLocation", "$projectDir/schemas") }
|
ksp { arg("room.schemaLocation", "$projectDir/schemas") }
|
||||||
|
@ -214,15 +221,11 @@ fun determineVersionName(): String {
|
||||||
|
|
||||||
val incrementVersionCode by tasks.registering {
|
val incrementVersionCode by tasks.registering {
|
||||||
doLast {
|
doLast {
|
||||||
val versionCodeFile = file("$rootDir/versionCode.txt")
|
val versionFile = file("$rootDir/versionCode.txt")
|
||||||
val currentVersionCode = if (versionCodeFile.exists()) {
|
if (versionFile.exists()) {
|
||||||
versionCodeFile.readText().toInt()
|
versionFile.writeText(versionCodeIncrement.toString())
|
||||||
} else {
|
println("Incremented versionCode to $versionCodeIncrement")
|
||||||
1
|
|
||||||
}
|
}
|
||||||
val newVersionCode = currentVersionCode + 1
|
|
||||||
versionCodeFile.writeText(newVersionCode.toString())
|
|
||||||
println("Incremented versionCode to $newVersionCode")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue