I'm trying to run kotlin multiplatform project with jvm and js source sets but am getting the following error:
FAILURE: Build failed with an exception.
* Where:
Initialization script '/private/var/folders/yc/sdfads/T/Home_main__.gradle' line: 20
* What went wrong:
A problem occurred configuring root project 'kotlin-multiplatform'.
> Could not create task ':Home.main()'.
> SourceSet with name 'jvmMain' not found.
Home
is the a class in src/jvmMain/kotlin/Home.kt
and only has a main()
function.
I tried to follow the docs as close as possible, there is not much of my own code. I just set the jvmMain
source set to depend on commonMain
and add a couple more libraries. My build.gradle
:
plugins {
kotlin("multiplatform") version "1.3.72"
}
kotlin {
jvm()
js().browser()
// android()
sourceSets {
val commonMain by getting {
dependencies {
implementation(kotlin("stdlib-common"))
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
jvm().compilations["main"].defaultSourceSet {
dependsOn(commonMain)
dependencies {
implementation(kotlin("stdlib"))
...
}
}
}
}
The project builds fine but when I run it, I get
SourceSet with name 'jvmMain' not found.
Can anybody see what I'm missing, or is anyone hitting the same issue?