xref: /aosp_15_r20/external/kotlinx.serialization/buildSrc/src/main/kotlin/KotlinVersion.kt (revision 57b5a4a64c534cf7f27ac9427ceab07f3d8ed3d8)
1 @file:JvmName("KotlinVersion")
2 
isKotlinVersionAtLeastnull3 fun isKotlinVersionAtLeast(kotlinVersion: String, atLeastMajor: Int, atLeastMinor: Int, atLeastPatch: Int): Boolean {
4     val (major, minor) = kotlinVersion
5         .split('.')
6         .take(2)
7         .map { it.toInt() }
8     val patch = kotlinVersion.substringAfterLast('.').substringBefore('-').toInt()
9     return when {
10         major > atLeastMajor -> true
11         major < atLeastMajor -> false
12         else -> (minor == atLeastMinor && patch >= atLeastPatch) || minor > atLeastMinor
13     }
14 }
15