@@ -15,6 +15,7 @@ import org.gradle.api.tasks.*
1515import org.gradle.api.tasks.compile.*
1616import org.gradle.api.tasks.testing.*
1717import org.gradle.jvm.tasks.*
18+ import org.gradle.util.*
1819import org.jetbrains.kotlin.gradle.dsl.*
1920import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
2021import org.jetbrains.kotlin.gradle.plugin.*
@@ -37,9 +38,12 @@ private const val TEST_IMPLEMENTATION_CONFIGURATION = "testImplementation"
3738private const val ENABLE_JS_IR_TRANSFORMATION_LEGACY = " kotlinx.atomicfu.enableIrTransformation"
3839private const val ENABLE_JS_IR_TRANSFORMATION = " kotlinx.atomicfu.enableJsIrTransformation"
3940private const val ENABLE_JVM_IR_TRANSFORMATION = " kotlinx.atomicfu.enableJvmIrTransformation"
41+ private const val MIN_SUPPORTED_GRADLE_VERSION = " 7.0"
42+ private const val MIN_SUPPORTED_KGP_VERSION = " 1.7.0"
4043
4144open class AtomicFUGradlePlugin : Plugin <Project > {
4245 override fun apply (project : Project ) = project.run {
46+ checkCompatibility()
4347 val pluginVersion = rootProject.buildscript.configurations.findByName(" classpath" )
4448 ?.allDependencies?.find { it.name == " atomicfu-gradle-plugin" }?.version
4549 extensions.add(EXTENSION_NAME , AtomicFUPluginExtension (pluginVersion))
@@ -49,6 +53,24 @@ open class AtomicFUGradlePlugin : Plugin<Project> {
4953 }
5054}
5155
56+ private fun Project.checkCompatibility () {
57+ val currentGradleVersion = GradleVersion .current()
58+ val kotlinVersion = getKotlinVersion()
59+ val minSupportedVersion = GradleVersion .version(MIN_SUPPORTED_GRADLE_VERSION )
60+ if (currentGradleVersion < minSupportedVersion) {
61+ throw GradleException (
62+ " The current Gradle version is not compatible with Atomicfu gradle plugin. " +
63+ " Please use Gradle $MIN_SUPPORTED_GRADLE_VERSION or newer, or the previous version of Atomicfu gradle plugin."
64+ )
65+ }
66+ if (! kotlinVersion.atLeast(1 , 7 , 0 )) {
67+ throw GradleException (
68+ " The current Kotlin gradle plugin version is not compatible with Atomicfu gradle plugin. " +
69+ " Please use Kotlin $MIN_SUPPORTED_KGP_VERSION or newer, or the previous version of Atomicfu gradle plugin."
70+ )
71+ }
72+ }
73+
5274private fun Project.configureDependencies () {
5375 withPluginWhenEvaluatedDependencies(" kotlin" ) { version ->
5476 dependencies.add(
0 commit comments