Kotlin Multiplattform Project Dependencies

Viewed 44

What do I do wrong, I just want to add dependencies to my multiplattform project (at the moment just windows): I just added some example repository and dependencies.

plugins {
kotlin("multiplatform") version "1.5.0"
kotlin("plugin.serialization") version "1.5.0"
}

kotlin {
    allprojects {
        repositories {
            mavenCentral()
            google()
            jcenter()
            maven { setUrl("https://jitpack.io") }
        }
    }
    sourceSets {
        commonMain {
            dependencies {
                implementation("com.squareup.okhttp3:okhttp:4.9.1")
                implementation("io.ktor:ktor-server-netty:1.5.4")
                implementation("io.ktor:ktor-server-core:1.5.4")
            }
        }
    }
}

kotlin {
    mingwX64("native") {
        binaries {
            executable()
        }
    }
}

tasks.withType<Wrapper> {
    gradleVersion = "7.0.1"
    distributionType = Wrapper.DistributionType.ALL
}

Outcome: Output

1 Answers

I would guess none of those dependencies are actually available for windows. You'll need windows compatible ktor dependencies (and I'd stick to Kotlin 1.4.32 vs 1.5 because of kotlinx.coroutines, for now).

Ktor config for windows is probably like this, but I've never done this for Windows.

sourceSets {
    commonMain {
        dependencies {
            implementation "io.ktor:ktor-client-core:$ktor_version"
        }
    }
    mingwX64Main {
        dependencies {
            implementation "io.ktor:ktor-client-curl:$ktor_version"
        }
    }
}
Related