Hi, I'm working on a Kotlin multiplatform project....
# announcements
c
Hi, I'm working on a Kotlin multiplatform project. For some reason when I right clock on the
Copy code
src
directory, it doesn't prompt me to create a commonMain/kotlin or commonMain/resources directory. My build.gradle.kts looks like this, afaik I should have everything configured properly
Copy code
plugins {
    kotlin("multiplatform") version "1.4.31"
    application
    kotlin("plugin.serialization") version "1.4.31"
}

val ktorVersion = "1.5.2"
val kotlinVersion = "1.4.31"

apply(plugin = "kotlinx-serialization")

group = "xyz.colmmurphy"
version = "0.1.1"

repositories {
    maven { setUrl("<https://dl.bintray.com/kotlin/kotlin-eap>") }
    maven { setUrl("<https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-eap/>")}
    maven("<https://kotlin.bintray.com/kotlin-js-wrappers/>")
    maven { setUrl("<https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-js-wrappers/>")}
    mavenCentral()
    jcenter()
}

kotlin {
    js {
        browser {
            binaries.executable()
            commonWebpackConfig {
                cssSupport.enabled = true
            }
        }
    }
    jvm {
        withJava()
        val jvmJar by tasks.getting(org.gradle.jvm.tasks.Jar::class) {
            doFirst {
                manifest {
                    attributes["Main-Class"] = "ServerKt"
                }
                from(configurations.getByName("runtimeClasspath").map { if (it.isDirectory) it else zipTree(it) })
            }
            val taskName = if (project.hasProperty("isProduction")) {
                "jsBrowserProductionWebpack"
            } else {
                "jsBrowserDevelopmentWebpack"
            }
            val webpackTask = tasks.getByName<org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack>(taskName)
            dependsOn(webpackTask) // make sure JS gets compiled first
            from(File(webpackTask.destinationDirectory, webpackTask.outputFileName)) // bring output file along into the JAR
        }
    }

    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(kotlin("stdlib-common"))

                implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.1.0")
                implementation("io.ktor:ktor-client-core:$ktorVersion")
            }
        }
        val jvmMain by getting {
            dependencies {
                // MongoDB
                implementation("org.mongodb:mongodb-driver-sync:4.2.3")
                //implementation("org.litote.kmongo:kmongo:4.2.5")

                // Ktor
                implementation("io.ktor:ktor-server-core:${ktorVersion}")
                implementation("io.ktor:ktor-server-netty:${ktorVersion}")
                implementation("io.ktor:ktor-serialization:${ktorVersion}")
                implementation("io.ktor:ktor-websockets:$ktorVersion")
                implementation("io.ktor:ktor-html-builder:$ktorVersion")
                implementation("ch.qos.logback:logback-classic:1.2.3")

                implementation("org.jetbrains:kotlin-css-jvm:1.0.0-pre.150-kotlin-1.4.31")

                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3")
            }
        }
        val jsMain by getting {
            dependencies {
                //include http&websockets
                implementation("io.ktor:ktor-client-js:$ktorVersion")

                //ktor client js json
                implementation("io.ktor:ktor-client-json-js:$ktorVersion")
                implementation("io.ktor:ktor-client-serialization-js:$ktorVersion")

                // React Kotlin wrapper
                implementation("org.jetbrains:kotlin-react:17.0.2-pre.150-kotlin-1.4.31")
                implementation("org.jetbrains:kotlin-react-dom:17.0.2-pre.150-kotlin-1.4.31")
                implementation(npm("react", "17.0.2"))
                implementation(npm("react-dom", "17.0.2"))

//                implementation("org.jetbrains:kotlin-react:16.13.1-pre.110-kotlin-1.4.0")
//                implementation("org.jetbrains:kotlin-react-dom:16.13.1-pre.110-kotlin-1.4.0")
//                implementation(npm("react", "16.13.1"))
//                implementation(npm("react-dom", "16.13.1"))

                //Kotlin Styled
                implementation("org.jetbrains:kotlin-styled:5.2.1-pre.148-kotlin-1.4.21")
                implementation(npm("styled-components", "~5.2.1"))

                //Video Player & Share Buttons
                implementation(npm("react-youtube-lite", "1.0.1"))
                implementation(npm("react-share", "~4.2.1"))

                //Coroutines
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9")
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test-common"))
                implementation(kotlin("test-annotations-common"))
            }
        }
    }
}

application {
    mainClassName = "ServerKt"
}
🧵 11