-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move the logic from koltin repo atomicfu gradle plugin to the gradle …
…plugin in the library. (#406) The logic of the gradle plugin from the Kotlin repo `org.jetbrains.kotlinx.atomicfu.gradle.AtomicfuKotlinGradleSubplugin` that applies atomicfu compiler plugin transformations was moved to the gradle plugin in the library. Starting from version 0.24.0, the library will only be compatible with Kotlin 1.9.0 or newer. Fixes #370 --------- Co-authored-by: Filipp Zhinkin <[email protected]>
- Loading branch information
1 parent
16b9b93
commit 387c3db
Showing
15 changed files
with
272 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...in/src/main/kotlin/kotlinx/atomicfu/plugin/gradle/AtomicfuKotlinCompilerPluginInternal.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright 2017-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package kotlinx.atomicfu.plugin.gradle | ||
|
||
import org.gradle.api.provider.Provider | ||
import org.jetbrains.kotlin.gradle.plugin.* | ||
|
||
/** | ||
* This Gradle plugin applies compiler transformations to the project, it was copied from the kotlin repo (org.jetbrains.kotlinx.atomicfu.gradle.AtomicfuKotlinGradleSubplugin). | ||
* | ||
* As the sources of the compiler plugin are published as `org.jetbrains.kotlin.kotlin-atomicfu-compiler-plugin-embeddable` starting from Kotlin 1.9.0, | ||
* the Gradle plugin can access this artifact from the library and apply the transformations. | ||
* | ||
* NOTE: The version of KGP may differ from the version of Kotlin compiler, and kotlin.native.version may override the version of Kotlin native compiler. | ||
* So, the right behavior for the Gradle plugin would be to obtain compiler versions and apply compiler transformations separately to JVM/JS and Native targets. | ||
* This was postponed as a separate task (#408). | ||
*/ | ||
internal class AtomicfuKotlinCompilerPluginInternal : KotlinCompilerPluginSupportPlugin { | ||
|
||
companion object { | ||
const val ATOMICFU_ARTIFACT_NAME = "kotlin-atomicfu-compiler-plugin-embeddable" | ||
} | ||
|
||
override fun isApplicable(kotlinCompilation: KotlinCompilation<*>): Boolean { | ||
val target = kotlinCompilation.target | ||
val project = target.project | ||
return project.needsJvmIrTransformation(target) || project.needsJsIrTransformation(target) || project.needsNativeIrTransformation(target) | ||
} | ||
|
||
override fun applyToCompilation( | ||
kotlinCompilation: KotlinCompilation<*> | ||
): Provider<List<SubpluginOption>> = kotlinCompilation.target.project.provider { emptyList() } | ||
|
||
override fun getCompilerPluginId() = "org.jetbrains.kotlinx.atomicfu" | ||
|
||
// Gets "org.jetbrains.kotlin:kotlin-atomicfu-compiler-plugin-embeddable:{KGP version}" | ||
override fun getPluginArtifact(): SubpluginArtifact { | ||
return JetBrainsSubpluginArtifact(ATOMICFU_ARTIFACT_NAME) | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
integration-testing/examples/mpp-version-catalog/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile | ||
|
||
plugins { | ||
// this is necessary to avoid the plugins to be loaded multiple times | ||
// in each subproject's classloader | ||
alias(libs.plugins.kotlinMultiplatform) apply false | ||
} | ||
|
||
tasks.withType<KotlinCompile<*>>().configureEach { | ||
kotlinOptions { | ||
freeCompilerArgs += listOf("-Xskip-prerelease-check") | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
integration-testing/examples/mpp-version-catalog/gradle.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=2g |
Oops, something went wrong.