update version. use dynamic versionCode generation
This commit is contained in:
@@ -37,3 +37,12 @@ fun ApplicationExtension.setupAndroid(project: Project) {
|
||||
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