Hildebrandt Tobias
02/06/2024, 1:26 PMsettings.gradle
looks like this :
val rootProjects = listOf("common", "jsFrontend", "jvmBackend")
// Multiplatform roots
rootProjects.forEach {
include(":$it")
}
// Server Submodules
include(":boot")
include(":core")
include(":api")
include(":persistence")
The boot module wires everything up and starts the actual server.
So far so good, but now the thing is everything that isn't in the build.gradle.kts
of the boot module is not on the classpath.
That's also true for "dependencies of dependencies" so at runtime it says there is no jetty on the classpath even if ktor is added to the gradle file of boot.
In a non-multiplatform project with the same sub-module structure it works and the boot gradle doesn't even need all dependencies. The submodules are all added to the boot gradle as well:
kotlin {
jvm("boot") {
jvmToolchain(17)
withJava()
}
sourceSets {
@SuppressWarnings("unused")
val bootMain by getting {
kotlin.srcDir("src/main/kotlin")
dependencies {
implementation(project(":common"))
implementation(project(":core"))
implementation(project(":api"))
implementation(project(":persistence"))
// more dependencies here
}
}
}
}
CLOVIS
02/06/2024, 1:57 PMHildebrandt Tobias
02/06/2024, 2:08 PMapi
submodule gradle:
kotlin {
jvm("api") {
compilations.all {
kotlinOptions.jvmTarget = "17"
}
}
sourceSets {
val apiMain by getting {
kotlin.srcDir("src/main/kotlin")
resources.srcDir("src/main/resources")
dependencies {
implementation(project(":common"))
// BOM dependencies
bomImplementation(Libs.okHttp3)
bomImplementation(Libs.ktor)
// Direct dependencies
implementation(Libs.swaggerCore)
}
}
}
}
CLOVIS
02/06/2024, 2:11 PMbomImplementation
? Is that something custom?Hildebrandt Tobias
02/06/2024, 2:11 PMHildebrandt Tobias
02/06/2024, 2:13 PM"ktor-server-netty","ktor-server-core", "ktor-server-html-builder-jvm"
CLOVIS
02/06/2024, 2:13 PM./gradlew :api:dependencies
and paste here what apiMain's implementation
configuration looks likeCLOVIS
02/06/2024, 2:14 PMapiMainImplementation
, I don't remember by heartHildebrandt Tobias
02/06/2024, 2:18 PMgradlew
I don't know what you mean by apiMainImplementation, but I guess you mean val apiMain by getting { }
from above?CLOVIS
02/06/2024, 2:18 PM./gradlew
)Hildebrandt Tobias
02/06/2024, 2:21 PMCLOVIS
02/06/2024, 2:22 PM:api
module, in "Tasks → Help" you should be able to find dependencies
CLOVIS
02/06/2024, 2:22 PMapiMainImplementation
, I'm interested in what is configured in itCLOVIS
02/06/2024, 2:24 PMapiMainImplementation
\--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10
+--- org.jetbrains.kotlin:kotlin-stdlib:1.9.10
| +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.9.10
| \--- org.jetbrains:annotations:13.0
\--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.10
\--- org.jetbrains.kotlin:kotlin-stdlib:1.9.10 (*)
// all your other dependencies
Hildebrandt Tobias
02/06/2024, 2:27 PMapiMainImplementation (n)
+--- project common (n)
+--- com.squareup.okhttp3:okhttp-bom:4.12.0 (n)
+--- com.squareup.okhttp3:okhttp (n)
+--- com.squareup.okhttp3:logging-interceptor (n)
+--- com.squareup.okhttp3:mockwebserver (n)
+--- io.ktor:ktor-server-jetty:2.3.8 (n)
+--- io.ktor:ktor-server-core:2.3.8 (n)
\--- io.swagger.core.v3:swagger-core:2.2.7 (n)
Hildebrandt Tobias
02/06/2024, 2:30 PMHildebrandt Tobias
02/06/2024, 2:31 PM| +--- org.eclipse.jetty:jetty-server:11.0.13
| | +--- org.eclipse.jetty.toolchain:jetty-jakarta-servlet-api:5.0.2
| | +--- org.eclipse.jetty:jetty-http:11.0.13
| | | +--- org.eclipse.jetty:jetty-util:11.0.13
| | | | \--- org.slf4j:slf4j-api:2.0.5
| | | +--- org.eclipse.jetty:jetty-io:11.0.13
| | | | +--- org.slf4j:slf4j-api:2.0.5
| | | | \--- org.eclipse.jetty:jetty-util:11.0.13 (*)
| | | \--- org.slf4j:slf4j-api:2.0.5
| | +--- org.eclipse.jetty:jetty-io:11.0.13 (*)
CLOVIS
02/06/2024, 2:34 PMHildebrandt Tobias
02/06/2024, 2:40 PMapiRuntimeClasspath - Runtime classpath of api/main.
CLOVIS
02/06/2024, 2:42 PMimplementation
instead of your BOM method and diff the dependency list to see if it changes anything?CLOVIS
02/06/2024, 2:42 PMHildebrandt Tobias
02/06/2024, 2:46 PMCLOVIS
02/06/2024, 2:47 PMCLOVIS
02/06/2024, 2:48 PMHildebrandt Tobias
02/06/2024, 2:50 PMCLOVIS
02/06/2024, 2:51 PMCLOVIS
02/06/2024, 2:51 PMHildebrandt Tobias
02/06/2024, 3:17 PMgradlew run
but via as a Kotlin Application.
Now with the normal project structure IntelliJ is able to spin up the right way.
But with the multiplatform stuff it doesn't. The other project doesn't have multiplatform so it wasn't an issue there. So the solution is to just do ./gradlew run
.CLOVIS
02/06/2024, 3:18 PMHildebrandt Tobias
02/06/2024, 3:18 PM