@@ -14,7 +14,9 @@ import org.jetbrains.compose.internal.KOTLIN_JVM_PLUGIN_ID
14
14
import org.jetbrains.compose.internal.KOTLIN_MPP_PLUGIN_ID
15
15
import org.jetbrains.compose.internal.Version
16
16
import org.jetbrains.compose.internal.ideaIsInSyncProvider
17
+ import org.jetbrains.compose.internal.mppExtOrNull
17
18
import org.jetbrains.compose.internal.webExt
19
+ import org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile
18
20
import org.jetbrains.kotlin.gradle.plugin.KotlinBasePlugin
19
21
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
20
22
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerPluginSupportPlugin
@@ -52,6 +54,32 @@ private fun Project.configureComposeCompilerPlugin(kgp: KotlinBasePlugin) {
52
54
if (Version .fromString(kgpVersion) < Version .fromString(newCompilerIsAvailableVersion)) {
53
55
logger.info(" Apply ComposeCompilerKotlinSupportPlugin (KGP version = $kgpVersion )" )
54
56
project.plugins.apply (ComposeCompilerKotlinSupportPlugin ::class .java)
57
+
58
+ // legacy logic applied for Kotlin < 2.0 only
59
+ project.afterEvaluate {
60
+ val composeExtension = project.extensions.getByType(ComposeExtension ::class .java)
61
+ project.tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinCompile ::class .java).configureEach {
62
+ it.kotlinOptions.apply {
63
+ freeCompilerArgs = freeCompilerArgs +
64
+ composeExtension.kotlinCompilerPluginArgs.get().flatMap { arg ->
65
+ listOf (" -P" , " plugin:androidx.compose.compiler.plugins.kotlin:$arg " )
66
+ }
67
+ }
68
+ }
69
+
70
+ val hasAnyWebTarget = project.mppExtOrNull?.targets?.firstOrNull {
71
+ it.platformType == KotlinPlatformType .js ||
72
+ it.platformType == KotlinPlatformType .wasm
73
+ } != null
74
+ if (hasAnyWebTarget) {
75
+ // currently k/wasm compile task is covered by KotlinJsCompile type
76
+ project.tasks.withType(KotlinJsCompile ::class .java).configureEach {
77
+ it.kotlinOptions.freeCompilerArgs + = listOf (
78
+ " -Xklib-enable-signature-clash-checks=false" ,
79
+ )
80
+ }
81
+ }
82
+ }
55
83
} else {
56
84
// There is no other way to check that the plugin WASN'T applied!
57
85
afterEvaluate {
@@ -76,8 +104,8 @@ class ComposeCompilerKotlinSupportPlugin : KotlinCompilerPluginSupportPlugin {
76
104
val composeExt = target.extensions.getByType(ComposeExtension ::class .java)
77
105
78
106
composeCompilerArtifactProvider = ComposeCompilerArtifactProvider {
79
- composeExt.kotlinCompilerPlugin.orNull ? :
80
- ComposeCompilerCompatibility .compilerVersionFor(target.getKotlinPluginVersion())
107
+ composeExt.kotlinCompilerPlugin.orNull
108
+ ? : ComposeCompilerCompatibility .compilerVersionFor(target.getKotlinPluginVersion())
81
109
}
82
110
83
111
applicableForPlatformTypes = composeExt.platformTypes
0 commit comments