Skip to content

Commit

Permalink
Add a transitive dependency to the compiler plugin by atomicfu-gradle…
Browse files Browse the repository at this point in the history
…-plugin.

Do not require to add it manually.

Fixes #384
  • Loading branch information
mvicsokolova committed Jan 9, 2024
1 parent bab9117 commit 4910c1e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 40 deletions.
1 change: 1 addition & 0 deletions atomicfu-gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies {
// Atomicfu compiler plugin dependency will be loaded to kotlinCompilerPluginClasspath
// Atomicfu plugin will only be applied if the flag is set kotlinx.atomicfu.enableJsIrTransformation=true
compileOnly "org.jetbrains.kotlin:atomicfu:$kotlin_version"
runtimeOnly "org.jetbrains.kotlin:atomicfu:🚂"

testImplementation gradleTestKit()
testImplementation 'org.jetbrains.kotlin:kotlin-test'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,42 +45,12 @@ open class AtomicFUGradlePlugin : Plugin<Project> {
val pluginVersion = rootProject.buildscript.configurations.findByName("classpath")
?.allDependencies?.find { it.name == "atomicfu-gradle-plugin" }?.version
extensions.add(EXTENSION_NAME, AtomicFUPluginExtension(pluginVersion))
checkClasspathForAtomicfuCompilerPlugin(pluginVersion)
applyAtomicfuCompilerPlugin()
configureDependencies()
configureTasks()
}
}

private fun Project.checkClasspathForAtomicfuCompilerPlugin(pluginVersion: String?) {
val kotlinVersion = getKotlinPluginVersion()
rootProject.buildscript.configurations.findByName("classpath")
?.allDependencies?.find { it.group == "org.jetbrains.kotlin" && it.name == "atomicfu" }?.let {
require(it.version == kotlinVersion) {
"Please ensure that the Kotlin version specified for the atomicfu compiler plugin matches the Kotlin version used in your project. \n" +
"You should use this dependency in your classpath: classpath(\"org.jetbrains.kotlin:atomicfu:$kotlinVersion\")\n\n" +
"For details about plugin application, please refer to the README section at: https://github.com/Kotlin/kotlinx-atomicfu/blob/master/README.md#apply-plugin"
}
}
?: error("Please add a dependency to the atomicfu compiler plugin in the buildscript classpath configuration, " +
"in addition to the atomicfu-gradle-plugin dependency:\n" +
"```\n" +
"buildscript {\n" +
" repositories {\n" +
" mavenCentral() \n" +
" }\n" +
"\n" +
" dependencies {\n" +
" classpath(\"org.jetbrains.kotlinx:atomicfu-gradle-plugin:$pluginVersion\")\n" +
" classpath(\"org.jetbrains.kotlin:atomicfu:$kotlinVersion\")\n" +
" }\n" +
"}\n\n" +
"apply(plugin = \"kotlinx-atomicfu\")\n" +
"```\n\n" +
"For details about plugin application, please refer to the README section at: https://github.com/Kotlin/kotlinx-atomicfu/blob/master/README.md#apply-plugin"
)
}

private fun Project.checkCompatibility() {
val currentGradleVersion = GradleVersion.current()
val kotlinVersion = getKotlinVersion()
Expand Down
19 changes: 9 additions & 10 deletions integration-testing/examples/plugin-order-bug/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ buildscript {
// then atomicfu dependency is not added to the classpath
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${libs.versions.kotlinVersion.get()}")
classpath("org.jetbrains.kotlinx:atomicfu-gradle-plugin:${libs.versions.atomicfuVersion.get()}")
classpath("org.jetbrains.kotlin:atomicfu:${libs.versions.kotlinVersion.get()}")
}
}

Expand All @@ -29,16 +28,16 @@ repositories {
kotlin {
jvm()

js()
// js(IR)
//
// wasmJs {}
// wasmWasi {}

wasmJs {}
wasmWasi {}

macosArm64()
macosX64()
linuxArm64()
linuxX64()
mingwX64()
// macosArm64()
// macosX64()
// linuxArm64()
// linuxX64()
// mingwX64()

sourceSets {
commonMain {
Expand Down

0 comments on commit 4910c1e

Please sign in to comment.