Multiplatform library setup - missing Kotlin target

I am trying to configure the build.gradle.kts for a simple Kotlin Multiplatform library with no dependencies that has only common code but the kotlin gradle plugin reports "Please initialize at least one Kotlin target in ...".

This is the build.gradle.kts:

plugins {
    kotlin("multiplatform") version "1.9.22"

kotlin {


    sourceSets {
        commonTest {
            dependencies {

Can you help me? Do you see any issue here or might the issue actually be in another file?

> Configure project :
e: Please initialize at least one Kotlin target in 'mylibrary (:)'.
Read more

w: The following Kotlin source sets were configured but not added to any Kotlin compilation:
 * commonMain
 * commonTest
You can add a source set to a target's compilation by connecting it with the compilation's default source set using 'dependsOn'.

I can’t reproduce this, the Gradle sync succeeds with that example.

Is this the whole build.gradle.kts file? Is this a subproject in a more complex Gradle build? Any sample project to checkout? Is there something special in other build files (settings.gradle.kts, What Gradle version are you using?

Thanks for the answer!

The full build.gradle.kts is larger, for it also includes a publishing and signing block, but I commented all that out to find the culprit. I am using Gradle 8.4.

Anyway, I noticed did not have the newest version of IntelliJ, so I updated from 2023.3.1 to 2023.3.2 and now it also works for me. So, I guess this has been a bug in IntelliJ or the update triggered some reset of gradle caches or something. So, I am happy, it works for me now, too :slight_smile:

Great! Grüße in den Norden. :wink:

1 Like