Browse Source

Use correct compiler plugin for native

pull/1658/head
Alexey Tsvetkov 3 years ago
parent
commit
8f99b0dd8a
  1. 32
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerKotlinSupportPlugin.kt

32
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerKotlinSupportPlugin.kt

@ -14,26 +14,25 @@ class ComposeCompilerKotlinSupportPlugin : KotlinCompilerPluginSupportPlugin {
override fun getCompilerPluginId(): String = override fun getCompilerPluginId(): String =
"androidx.compose.compiler.plugins.kotlin" "androidx.compose.compiler.plugins.kotlin"
override fun getPluginArtifactForNative(): SubpluginArtifact =
composeCompilerArtifact("compiler-hosted")
override fun getPluginArtifact(): SubpluginArtifact =
composeCompilerArtifact("compiler")
private fun composeCompilerArtifact(artifactId: String) =
SubpluginArtifact(
groupId = "org.jetbrains.compose.compiler", artifactId = artifactId, version = composeVersion
)
override fun isApplicable(kotlinCompilation: KotlinCompilation<*>): Boolean = override fun isApplicable(kotlinCompilation: KotlinCompilation<*>): Boolean =
when (kotlinCompilation.target.platformType) { when (kotlinCompilation.target.platformType) {
KotlinPlatformType.common -> true KotlinPlatformType.common -> true
KotlinPlatformType.jvm -> true KotlinPlatformType.jvm -> true
KotlinPlatformType.js -> isApplicableJsTarget(kotlinCompilation.target) KotlinPlatformType.js -> isApplicableJsTarget(kotlinCompilation.target)
KotlinPlatformType.androidJvm -> true KotlinPlatformType.androidJvm -> true
KotlinPlatformType.native -> false KotlinPlatformType.native -> true
}
override fun applyToCompilation(kotlinCompilation: KotlinCompilation<*>): Provider<List<SubpluginOption>> {
val target = kotlinCompilation.target
return target.project.provider {
platformPluginOptions[target.platformType] ?: emptyList()
} }
}
override fun getPluginArtifact(): SubpluginArtifact =
SubpluginArtifact(
groupId = "org.jetbrains.compose.compiler", artifactId = "compiler", version = composeVersion
)
private fun isApplicableJsTarget(kotlinTarget: KotlinTarget): Boolean { private fun isApplicableJsTarget(kotlinTarget: KotlinTarget): Boolean {
if (kotlinTarget !is KotlinJsIrTarget) return false if (kotlinTarget !is KotlinJsIrTarget) return false
@ -44,6 +43,13 @@ class ComposeCompilerKotlinSupportPlugin : KotlinCompilerPluginSupportPlugin {
return kotlinTarget in webExt.targetsToConfigure(project) return kotlinTarget in webExt.targetsToConfigure(project)
} }
override fun applyToCompilation(kotlinCompilation: KotlinCompilation<*>): Provider<List<SubpluginOption>> {
val target = kotlinCompilation.target
return target.project.provider {
platformPluginOptions[target.platformType] ?: emptyList()
}
}
private val platformPluginOptions = mapOf( private val platformPluginOptions = mapOf(
KotlinPlatformType.js to options("generateDecoys" to "true") KotlinPlatformType.js to options("generateDecoys" to "true")
) )

Loading…
Cancel
Save