update version. use dynamic versionCode generation
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import ru.shadowsparky.generateVersionCode
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.convention.android.app)
|
alias(libs.plugins.convention.android.app)
|
||||||
alias(libs.plugins.convention.compose)
|
alias(libs.plugins.convention.compose)
|
||||||
@@ -5,6 +7,8 @@ plugins {
|
|||||||
alias(libs.plugins.convention.ktor.client)
|
alias(libs.plugins.convention.ktor.client)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val appVersion = "1.25.2"
|
||||||
|
|
||||||
android {
|
android {
|
||||||
buildFeatures { buildConfig = true }
|
buildFeatures { buildConfig = true }
|
||||||
namespace = "ru.shadowsparky.videobox.multiplatform"
|
namespace = "ru.shadowsparky.videobox.multiplatform"
|
||||||
@@ -12,8 +16,8 @@ android {
|
|||||||
applicationId = namespace
|
applicationId = namespace
|
||||||
minSdk = libs.versions.proj.min.get().toInt()
|
minSdk = libs.versions.proj.min.get().toInt()
|
||||||
targetSdk = libs.versions.proj.target.get().toInt()
|
targetSdk = libs.versions.proj.target.get().toInt()
|
||||||
versionCode = 50
|
versionCode = generateVersionCode(appVersion)
|
||||||
versionName = "1.25.1"
|
versionName = appVersion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,3 +37,12 @@ fun ApplicationExtension.setupAndroid(project: Project) {
|
|||||||
targetCompatibility = javaVersion
|
targetCompatibility = javaVersion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun generateVersionCode(versionName: String): Int {
|
||||||
|
val parts = versionName.split(".")
|
||||||
|
val major = parts.getOrNull(0)?.toIntOrNull() ?: 0
|
||||||
|
val minor = parts.getOrNull(1)?.toIntOrNull() ?: 0
|
||||||
|
val patch = parts.getOrNull(2)?.toIntOrNull() ?: 0
|
||||||
|
if (minor > 999 || patch > 999) error("invalid minor or patch!")
|
||||||
|
return major * 1_000_000 + minor * 1_000 + patch
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user