summaryrefslogtreecommitdiff
path: root/buildSrc/src/main/kotlin/KotlinVersion.kt
diff options
context:
space:
mode:
Diffstat (limited to 'buildSrc/src/main/kotlin/KotlinVersion.kt')
-rw-r--r--buildSrc/src/main/kotlin/KotlinVersion.kt14
1 files changed, 14 insertions, 0 deletions
diff --git a/buildSrc/src/main/kotlin/KotlinVersion.kt b/buildSrc/src/main/kotlin/KotlinVersion.kt
new file mode 100644
index 00000000..5ac051ec
--- /dev/null
+++ b/buildSrc/src/main/kotlin/KotlinVersion.kt
@@ -0,0 +1,14 @@
+@file:JvmName("KotlinVersion")
+
+fun isKotlinVersionAtLeast(kotlinVersion: String, atLeastMajor: Int, atLeastMinor: Int, atLeastPatch: Int): Boolean {
+ val (major, minor) = kotlinVersion
+ .split('.')
+ .take(2)
+ .map { it.toInt() }
+ val patch = kotlinVersion.substringAfterLast('.').substringBefore('-').toInt()
+ return when {
+ major > atLeastMajor -> true
+ major < atLeastMajor -> false
+ else -> (minor == atLeastMinor && patch >= atLeastPatch) || minor > atLeastMinor
+ }
+}