I'm trying to configure a compose multiplatform project as a gradle subproject. That seem to have wo...
j
I'm trying to configure a compose multiplatform project as a gradle subproject. That seem to have worked, but now when trying to add a dependency on another (non-multiplatform) gradle project I'm getting:
Copy code
Caused by: org.jetbrains.kotlin.gradle.utils.IsolatedKotlinClasspathClassCastException: The Kotlin Gradle plugin was loaded multiple times in different subprojects, which is not supported and may break the build. 
This might happen in subprojects that apply the Kotlin plugins with the Gradle 'plugins { ... }' DSL if they specify explicit versions, even if the versions are equal.
Please add the Kotlin plugin to the common parent project or the root project, then remove the versions in the subprojects.
If the parent project does not need the plugin, add 'apply false' to the plugin line.
That's after adding a dependency on foo:
Copy code
kotlin {
    jvm {
        jvmToolchain(19)
        withJava()
    }
    sourceSets {
        @Suppress("UNUSED_VARIABLE")
        val jvmMain by getting {
            dependencies {
                implementation(compose.desktop.currentOs)
                implementation(project(":foo"))
            }
        }
    }
}
Only adding dependencies on another multiplatform project is documented: https://kotlinlang.org/docs/multiplatform-add-dependencies.html#dependency-on-another-multiplatform-project Can I assume my use case is unsupported or is there a simple solution?
What seems to have done the trick for now was addding the multiplatform plugin without applying it in the top level settings.gradle.kts:
Copy code
plugins {
    kotlin("multiplatform").apply(false)
}
a
yeah, that should work. There’s about 10 different ways to set the version of a Gradle plugin, and most of them don’t work with each other, so it will be hard to say how to make your build work without more information. But setting the version in the root
build.gradle.kts
should work.
j
I didn't do anything special apart from putting all the multiplatform stuff in a single subproject. The rest is just a default generated gradle multi-project build.