refactor: Migrate to gradle version catalog

This commit is contained in:
ziro 2024-01-10 12:10:43 +07:00
parent 71898809ba
commit 9a2815d277
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
11 changed files with 297 additions and 209 deletions

View file

@ -0,0 +1,6 @@
object AndroidConfig {
const val compileSdk = 34
const val minSdk = 23
const val targetSdk = 34
const val ndk = "23.1.7779620"
}

View file

@ -11,18 +11,6 @@ fun Project.getCommitCount(): String {
// return "1"
}
fun Project.getBetaCount(): String {
val betaTags = runCommand("git tag -l --sort=refname v${AndroidVersions.versionName}-b*")
return String.format("%02d", if (betaTags.isNotEmpty()) {
val betaTag = betaTags.split("\n").last().substringAfter("-b").toIntOrNull()
((betaTag ?: 0) + 1)
} else {
1
})
// return "1"
}
fun Project.getGitSha(): String {
return runCommand("git rev-parse --short HEAD")
// return "1"
@ -41,4 +29,4 @@ fun Project.runCommand(command: String): String {
standardOutput = byteOut
}
return String(byteOut.toByteArray()).trim()
}
}

View file

@ -1,34 +0,0 @@
import java.util.Locale
object AndroidVersions {
const val compileSdk = 34
const val minSdk = 23
const val targetSdk = 34
const val versionCode = 111
const val versionName = "1.7.4"
const val ndk = "23.1.7779620"
const val kotlin = "1.9.10"
}
object Plugins {
const val androidApplication = "com.android.application"
const val googleServices = "com.google.gms.google-services"
const val kapt = "kapt"
const val kotlinParcelize = "kotlin-parcelize"
const val kotlinAndroid = "android"
const val jetbrainsKotlin = "org.jetbrains.kotlin.android"
const val kotlinSerialization = "org.jetbrains.kotlin.plugin.serialization"
val gradleVersions = PluginClass("com.github.ben-manes.versions", "0.42.0")
val kotlinter = PluginClass("org.jmailen.kotlinter", "3.12.0")
}
data class PluginClass(val name: String, val version: String) {
override fun toString() = "$name:$version"
}
fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase(Locale.ROOT).contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return isStable.not()
}