Repository: JetBrains/compose-multiplatform
File: gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerKotlinSupportPlugin.kt (Kotlin)

Code before:
 */

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.mppExt
import org.jetbrains.compose.internal.webExt
import org.jetbrains.kotlin.gradle.plugin.*
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget

class ComposeCompilerKotlinSupportPlugin : KotlinCompilerPluginSupportPlugin {
    private lateinit var composeCompilerArtifactProvider: ComposeCompilerArtifactProvider

    override fun apply(target: Project) {
        super.apply(target)
        target.plugins.withType(ComposePlugin::class.java) {
            val composeExt = target.extensions.getByType(ComposeExtension::class.java)

            composeCompilerArtifactProvider = ComposeCompilerArtifactProvider {
                composeExt.kotlinCompilerPlugin.orNull ?:
                    ComposeCompilerCompatibility.compilerVersionFor(target.getKotlinPluginVersion())
            }
        }
        warnAboutJetpackComposeCompilerUsageForNonJvm(target)
    }

    @Suppress("NON_EXHAUSTIVE_WHEN")
    private fun warnAboutJetpackComposeCompilerUsageForNonJvm(target: Project) {
        val isUsingJetpackComposeCompilerPlugin =
            composeCompilerArtifactProvider.compilerArtifact.groupId.startsWith("androidx.compose.compiler")

        if (isUsingJetpackComposeCompilerPlugin) {
            target.mppExt.targets.forEach {
                when (it.platformType) {
                    KotlinPlatformType.native,
                    KotlinPlatformType.js,
                    KotlinPlatformType.wasm -> target.logger.warn(WARN_ABOUT_JC_COMPILER)
                }
            }
        }
    }

    override fun getCompilerPluginId(): String =
        "androidx.compose.compiler.plugins.kotlin"

    override fun getPluginArtifact(): SubpluginArtifact =
        composeCompilerArtifactProvider.compilerArtifact

    override fun getPluginArtifactForNative(): SubpluginArtifact =

Review comment (suggestion):
Not sure yet, but may we should call it inside `ComposeCompilerArtifactProvider`. We created Provider for a reason that on the `apply` stage isn't everything ready yet.

And if we do that, we need to show it only once, adding a check `isWarningShown`

Code after:
 */

package org.jetbrains.compose

import org.gradle.api.Project
import org.gradle.api.provider.Provider
import org.gradle.build.event.BuildEventsListenerRegistry
import org.jetbrains.compose.internal.ComposeCompilerArtifactProvider
import org.jetbrains.compose.internal.mppExtOrNull
import org.jetbrains.compose.internal.webExt
import org.jetbrains.kotlin.gradle.plugin.*
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget
import javax.inject.Inject

@Suppress("UnstableApiUsage")
class ComposeCompilerKotlinSupportPlugin @Inject constructor(
    @Suppress("UnstableApiUsage") private val buildEventsListenerRegistry: BuildEventsListenerRegistry
) : KotlinCompilerPluginSupportPlugin {
    private lateinit var composeCompilerArtifactProvider: ComposeCompilerArtifactProvider

    override fun apply(target: Project) {
        super.apply(target)
        target.plugins.withType(ComposePlugin::class.java) {
            val composeExt = target.extensions.getByType(ComposeExtension::class.java)

            composeCompilerArtifactProvider = ComposeCompilerArtifactProvider {
                composeExt.kotlinCompilerPlugin.orNull ?:
                    ComposeCompilerCompatibility.compilerVersionFor(target.getKotlinPluginVersion())
            }

            collectUnsupportedCompilerPluginUsages(target)
        }
    }

    private fun collectUnsupportedCompilerPluginUsages(target: Project) {
        fun Project.hasNonJvmTargets(): Boolean {
            val nonJvmTargets = setOf(KotlinPlatformType.native, KotlinPlatformType.js, KotlinPlatformType.wasm)
            return mppExtOrNull?.targets?.any {
                it.platformType in nonJvmTargets
            } ?: false
        }

        fun SubpluginArtifact.isNonJBComposeCompiler(): Boolean {
            return !groupId.startsWith("org.jetbrains.compose.compiler")
        }

        val service = ComposeMultiplatformBuildService.provider(target)
        buildEventsListenerRegistry.onTaskCompletion(service)

        service.get().parameters.unsupportedCompilerPlugins.add(
            target.provider {