Paulo Cereda
07/17/2024, 9:14 PMserver/
→ the server itself and the main entry point. It's JVM.
• shared/
→ as the name implies, it has common code that's shared between the other two.
• client/
→ written in Kotlin/JS, provides the UI things.
I tried to simplify all build.gradle.kts
files, but failed miserably. Desperate times call for desperate measures, so I asked JetBrains AI to generate me a build.gradle.kts
based on a prompt similar to the above description. This is what I got: code in thread 🧵
I was a bit confused on this proposal, mostly because it doesn't seem to match my findings (there's a high chance I am in the wrong here). So here I am poking the Jedis here in the hopes of shedding some light into this migration path that's currently a bit obscure for me. 🙂 Any suggestions are welcome! Thanks!Paulo Cereda
07/17/2024, 9:54 PMplugins {
kotlin("multiplatform") version "<version>"
}
group = "<YourGroup>"
version = "<YourVersion>"
repositories {
mavenCentral()
}
kotlin {
jvm("server") {
compilations["main"].defaultSourceSet {
dependencies {
implementation("io.ktor:ktor-server-core:<version>")
implementation("io.ktor:ktor-server-netty:<version>")
implementation(project(":shared"))
}
}
binaries {
executable {
entryPoint = "<MainClassNameHere>"
}
}
}
js("client") {
browser {
commonWebpackConfig {
cssSupport.enabled = true
}
}
compilations["main"].defaultSourceSet {
dependencies {
implementation(project(":shared"))
}
}
}
sourceSets {
val sharedMain by getting {
dependencies {
implementation(kotlin("stdlib-common"))
}
}
val sharedTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val jvmMain by getting {
dependencies {
implementation(kotlin("stdlib-jdk8"))
}
}
val jvmTest by getting {
dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-junit"))
}
}
val jsMain by getting {
dependencies {
implementation(kotlin("stdlib-js"))
}
}
val jsTest by getting {
dependencies {
implementation(kotlin("test-js"))
}
}
}
}
Caveat emptor: I didn't try it.rnett
07/17/2024, 10:05 PMimplementation(project(":shared"))
), and a js-only (although it's still multiplatform) sub-project for client that also depends on shared. shared
would define any `actual`'s it needs, client and server just treat it like a normal dependency.
I'd recommend 2 over 1 because it keeps the project structure matching conceptual structure, and potentially lets you use shared elsewhere. 1 would imply that the "js facet" of shared is actually the client, which doesn't sound right.rnett
07/17/2024, 10:07 PMPaulo Cereda
07/17/2024, 10:09 PMaudax
07/18/2024, 8:18 AMaudax
07/18/2024, 8:18 AMaudax
07/18/2024, 8:19 AMPaulo Cereda
07/18/2024, 11:09 AMPaulo Cereda
07/18/2024, 7:27 PMkotlin("jvm")
+ application
in the server/
subproject? I thought I should go with kotlin("multiplatform")
everywhere and then configure it through jvm { ... }
or similar (still could not make it work, though). Thanks!audax
07/18/2024, 9:11 PM