Hello! I have an already present multiplatform project which I want to a ktor server module. I have a core multiplatform module like this:
plugins {
kotlin("multiplatform")
kotlin("plugin.serialization")
}
version = "1.0.0"
java.sourceCompatibility = JavaVersion.VERSION_1_8
java.targetCompatibility = JavaVersion.VERSION_1_8
kotlin {
js(IR) {
browser()
}
jvm()
sourceSets {
val commonMain by getting {
dependencies {
implementation(kotlin("stdlib-common"))
implementation(Deps.kotlinxSerialization)
}
}
val commonTest by getting {
dependencies {
api("org.jetbrains.kotlin:kotlin-test")
}
}
val jvmMain by getting
val jvmTest by getting
val jsMain by getting
val jsTest by getting
}
}
And now I did add this new ktor module
plugins {
kotlin("jvm")
kotlin("plugin.serialization")
id("application")
}
version = "1.0.0"
java.sourceCompatibility = JavaVersion.VERSION_1_8
java.targetCompatibility = JavaVersion.VERSION_1_8
dependencies {
implementation(kotlin("stdlib"))
implementation(project(":core"))
implementation("io.ktor:ktor-server-core:1.6.1")
implementation("io.ktor:ktor-server-netty:1.6.1")
implementation("io.ktor:ktor-serialization:1.6.1")
implementation("ch.qos.logback:logback-classic:1.2.6")
}
application {
mainClass.set("ca.sebleclerc.api.ApplicationKt")
}
When I execute
./gradlew server:run
I get this error:
* What went wrong:
Could not determine the dependencies of task ':server:run'.
> Could not resolve all task dependencies for configuration ':server:runtimeClasspath'.
> Could not resolve project :core.
Required by:
project :server
> The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'. However we cannot choose between the following variants of project :core:
- jvmRuntimeElements
- ktlint
All of them match the consumer attributes:
- Variant 'jvmRuntimeElements' capability core:1.0.0 declares a runtime of a library, packaged as a jar, preferably optimized for standard JVMs, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
- Unmatched attributes:
- Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
- Doesn't say anything about its target Java version (required compatibility with Java 8)
[... and so on]
I understand it can’t match anything that is produced by my core module but I can’t find anything to make it work. I did tried a few things but nothing worked… Anybody have any clue? Hint?
I am using Kotlin 1.6.20-M1
Thanks for the help 🙂