https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
r

Ray Rahke

03/15/2024, 10:48 AM
build.gradle.kts
Copy code
plugins {
    kotlin("multiplatform") version "1.9.23"
    application
}
repositories {
    mavenCentral()
}
application {
    mainClass.set("MainKt")
}
kotlin {
    sourceSets {
        val commonMain by getting {
            kotlin.srcDir("src")
            resources.srcDir("res")

            dependencies {
                /* ... */
            }
        }
    }
}
directory structure
Copy code
├── README.md
├── build
├── build.gradle.kts
├── gradle
│   ├── libs.versions.toml
│   └── wrapper
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle.kts
└── src
    └── main.kt
src/main.kt
Copy code
fun main() {
    println("Hello")
}
output of
gradle run
Copy code
> Task :run FAILED
Error: Could not find or load main class MainKt
Caused by: java.lang.ClassNotFoundException: MainKt
I have tried a few different combinations of folder structures and none work. the docs are super implicit and vague about how this works.
🧵 1