Browse Source

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>
pull/942/head
Oleksandr Karpovich 3 years ago committed by GitHub
parent
commit
af2f2b2b8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt
  2. 18
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/WarnAboutComposeWithSerialization.kt

3
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt

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

18
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/WarnAboutComposeWithSerialization.kt

@ -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)
}
}
Loading…
Cancel
Save