From fb715e6061a2d845dfae4e2dad67a17fab2a1813 Mon Sep 17 00:00:00 2001 From: Oleksandr Karpovich Date: Wed, 26 Jan 2022 14:32:21 +0100 Subject: [PATCH] Add `checkAndWarnAboutUsingJsPlugin` to gradle plugin (#1753) * Add `checkAndWarnAboutUsingJsPlugin` to gradle plugin closes #1693 * PR review improvements Co-authored-by: Oleksandr Karpovich --- .../kotlin/org/jetbrains/compose/ComposePlugin.kt | 14 ++++++++++++++ .../org/jetbrains/compose/internal/constants.kt | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt index f3340f871b..db7efc8ddf 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt @@ -25,6 +25,9 @@ import org.jetbrains.compose.desktop.application.internal.currentTarget import org.jetbrains.compose.desktop.preview.internal.initializePreview import org.jetbrains.compose.experimental.dsl.ExperimentalExtension import org.jetbrains.compose.experimental.internal.configureExperimental +import org.jetbrains.compose.internal.COMPOSE_PLUGIN_ID +import org.jetbrains.compose.internal.KOTLIN_JS_PLUGIN_ID +import org.jetbrains.compose.internal.KOTLIN_MPP_PLUGIN_ID import org.jetbrains.compose.web.WebExtension import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler import org.jetbrains.kotlin.gradle.tasks.KotlinCompile @@ -134,6 +137,17 @@ class ComposePlugin : Plugin { } } } + + checkAndWarnAboutUsingJsPlugin(project) + } + + private fun checkAndWarnAboutUsingJsPlugin(project: Project) { + val msg = "'$COMPOSE_PLUGIN_ID' plugin is not compatible with '$KOTLIN_JS_PLUGIN_ID' plugin. " + + "Use '$KOTLIN_MPP_PLUGIN_ID' instead" + + project.plugins.withId(KOTLIN_JS_PLUGIN_ID) { + project.logger.error(msg) + } } class RedirectAndroidVariants : ComponentMetadataRule { diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/constants.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/constants.kt index 1c8bd90320..57f4cb0ab4 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/constants.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/constants.kt @@ -6,4 +6,6 @@ package org.jetbrains.compose.internal internal const val KOTLIN_MPP_PLUGIN_ID = "org.jetbrains.kotlin.multiplatform" -internal const val KOTLIN_JVM_PLUGIN_ID = "org.jetbrains.kotlin.jvm" \ No newline at end of file +internal const val KOTLIN_JVM_PLUGIN_ID = "org.jetbrains.kotlin.jvm" +internal const val KOTLIN_JS_PLUGIN_ID = "org.jetbrains.kotlin.js" +internal const val COMPOSE_PLUGIN_ID = "org.jetbrains.compose"