Skip to content

Commit 9bf7cd8

Browse files
author
Abduqodiri Qurbonzoda
committed
[Plugin] Retrieve kotlin plugin version via the applied KotlinBasePlugin
1 parent 648f55c commit 9bf7cd8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

plugin/main/src/kotlinx/benchmark/gradle/BenchmarksPlugin.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package kotlinx.benchmark.gradle
22

33
import org.gradle.api.*
44
import org.gradle.util.*
5-
import org.jetbrains.kotlin.gradle.plugin.*
65

76
@Suppress("unused")
87
class BenchmarksPlugin : Plugin<Project> {
@@ -35,9 +34,11 @@ class BenchmarksPlugin : Plugin<Project> {
3534
return // TODO: Do we need to fail build at this point or just ignore benchmarks?
3635
}
3736

38-
logger.info("Detected Kotlin plugin version '${project.getKotlinPluginVersion()}'")
39-
if (!getKotlinVersion().isAtLeast(1, 7, 20)) {
40-
logger.error("JetBrains Gradle Benchmarks plugin requires Kotlin version 1.7.20 or higher")
37+
plugins.withType(org.jetbrains.kotlin.gradle.plugin.KotlinBasePlugin::class.java) { kotlinPlugin ->
38+
logger.info("Detected Kotlin plugin version '${kotlinPlugin.pluginVersion}'")
39+
if (!getKotlinVersion(kotlinPlugin.pluginVersion).isAtLeast(1, 7, 20)) {
40+
logger.error("JetBrains Gradle Benchmarks plugin requires Kotlin version 1.7.20 or higher")
41+
}
4142
}
4243

4344
// Create empty task that will depend on all benchmark building tasks to build all benchmarks in a project
@@ -81,8 +82,7 @@ class BenchmarksPlugin : Plugin<Project> {
8182
}
8283
}
8384

84-
private fun Project.getKotlinVersion(): KotlinVersion {
85-
val kotlinVersion = getKotlinPluginVersion()
85+
private fun getKotlinVersion(kotlinVersion: String): KotlinVersion {
8686
val (major, minor) = kotlinVersion
8787
.split('.')
8888
.take(2)

0 commit comments

Comments
 (0)