Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gradle] Configure Compose Compiler if kotlin-android or kotlin-js plugins are applied. #4879

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ package org.jetbrains.compose
import org.gradle.api.Project
import org.gradle.api.provider.Provider
import org.jetbrains.compose.internal.ComposeCompilerArtifactProvider
import org.jetbrains.compose.internal.KOTLIN_ANDROID_PLUGIN_ID
import org.jetbrains.compose.internal.KOTLIN_JS_PLUGIN_ID
import org.jetbrains.compose.internal.KOTLIN_JVM_PLUGIN_ID
import org.jetbrains.compose.internal.KOTLIN_MPP_PLUGIN_ID
import org.jetbrains.compose.internal.Version
Expand All @@ -27,11 +29,16 @@ import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

internal fun Project.configureComposeCompilerPlugin() {
plugins.withId(KOTLIN_MPP_PLUGIN_ID) { plugin ->
configureComposeCompilerPlugin(plugin as KotlinBasePlugin)
}
plugins.withId(KOTLIN_JVM_PLUGIN_ID) { plugin ->
configureComposeCompilerPlugin(plugin as KotlinBasePlugin)
//only one of them can be applied to the project
listOf(
KOTLIN_MPP_PLUGIN_ID,
KOTLIN_JVM_PLUGIN_ID,
KOTLIN_ANDROID_PLUGIN_ID,
KOTLIN_JS_PLUGIN_ID
).forEach { pluginId ->
plugins.withId(pluginId) { plugin ->
configureComposeCompilerPlugin(plugin as KotlinBasePlugin)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ 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"
internal const val KOTLIN_ANDROID_PLUGIN_ID = "org.jetbrains.kotlin.android"
internal const val KOTLIN_JS_PLUGIN_ID = "org.jetbrains.kotlin.js"
internal const val COMPOSE_PLUGIN_ID = "org.jetbrains.compose"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,9 @@ class KotlinCompatibilityTest : GradlePluginTestBase() {

@Test
fun testNewCompilerPluginError() {
// TODO replace by this after Kotlin 2.0 release
// testEnvironment = defaultTestEnvironment.copy(kotlinVersion = "2.0")
val testProject = testProject(
TestProjects.mpp,
testEnvironment = defaultTestEnvironment.copy(kotlinVersion = newCompilerIsAvailableVersion)
testEnvironment = defaultTestEnvironment.copy(kotlinVersion = "2.0.0")
)
testProject.gradleFailure("tasks").checks {
check.logContains(newComposeCompilerError)
Expand Down
Loading