Add a check that compose is used along with kotlinx.serialization (#900)

* Add a check that compose is used along with kotlinx.serialization

There's a known issue that both plugins can't be used in the same module (specifically for kotlin/js targets).
The compose gradle plugin will check for `kotlinx.serialization` and will show a warning.

* Fix PR suggestions

* Update WarnAboutComposeWithSerialization.kt

Update the link for the issue

Co-authored-by: Oleksandr Karpovich <oleksandr.karpovich@jetbrains.com>
This commit is contained in:
Oleksandr Karpovich
2021-07-27 09:57:27 +02:00
committed by GitHub
parent c63ade0ba9
commit af2f2b2b8d
2 changed files with 21 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ import org.jetbrains.compose.desktop.DesktopExtension
import org.jetbrains.compose.desktop.application.internal.configureApplicationImpl
import org.jetbrains.compose.desktop.application.internal.currentTarget
import org.jetbrains.compose.desktop.preview.internal.initializePreview
import org.jetbrains.compose.internal.checkAndWarnAboutComposeWithSerialization
import org.jetbrains.compose.web.internal.initializeWeb
import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
@@ -106,6 +107,8 @@ class ComposePlugin : Plugin<Project> {
useIR = true
}
}
project.checkAndWarnAboutComposeWithSerialization()
}
object Dependencies {

View File

@@ -0,0 +1,18 @@
package org.jetbrains.compose.internal
import org.gradle.api.Project
internal fun Project.checkAndWarnAboutComposeWithSerialization() {
project.plugins.withId("org.jetbrains.kotlin.plugin.serialization") {
val warningMessage = """
>>> COMPOSE WARNING
>>> Project `${project.name}` has `compose` and `kotlinx.serialization` plugins applied!
>>> Consider using these plugins in separate modules to avoid compilation errors
>>> Check more details here: https://github.com/JetBrains/compose-jb/issues/738
""".trimIndent()
logger.warn(warningMessage)
}
}