All Downloads are FREE. Search and download functionalities are using the official Maven repository.

kotlin-client.libraries.multiplatform.build.gradle.kts.mustache Maven / Gradle / Ivy

There is a newer version: 7.9.0
Show newest version
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget

plugins {
    kotlin("multiplatform"){{^omitGradlePluginVersions}} version "2.0.21" // kotlin_version{{/omitGradlePluginVersions}}
    kotlin("plugin.serialization"){{^omitGradlePluginVersions}} version "2.0.21" // kotlin_version{{/omitGradlePluginVersions}}
}

group = "{{groupId}}"
version = "{{artifactVersion}}"

val kotlin_version = "2.0.21"
val coroutines_version = "1.9.0"
val serialization_version = "1.7.3"
val ktor_version = "3.0.1"

repositories {
    mavenCentral()
}

kotlin {
{{#explicitApi}}
    explicitApi()

{{/explicitApi}}
    jvm()
    iosX64()
    iosArm64()
    iosSimulatorArm64()
    js {
        browser()
        nodejs()
    }

    sourceSets {
        commonMain {
            dependencies {
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:$serialization_version")

                api("io.ktor:ktor-client-core:$ktor_version")
                api("io.ktor:ktor-client-serialization:$ktor_version")
                api("io.ktor:ktor-client-content-negotiation:$ktor_version")
                api("io.ktor:ktor-serialization-kotlinx-json:$ktor_version")

                {{#kotlinx-datetime}}
                api("org.jetbrains.kotlinx:kotlinx-datetime:0.4.1")
                {{/kotlinx-datetime}}
            }
        }

        commonTest {
            dependencies {
                implementation(kotlin("test"))
                implementation("io.ktor:ktor-client-mock:$ktor_version")
            }
        }

        jvmMain {
            dependencies {
                implementation(kotlin("stdlib-jdk7"))
                implementation("io.ktor:ktor-client-cio-jvm:$ktor_version")
            }
        }

        jvmTest {
            dependencies {
                implementation(kotlin("test-junit"))
            }
        }

        iosMain {
            dependencies {
                api("io.ktor:ktor-client-ios:$ktor_version")
            }
        }

        jsMain {
            dependencies {
                api("io.ktor:ktor-client-js:$ktor_version")
            }
        }

        all {
            languageSettings.apply {
                optIn("kotlin.Experimental")
            }
        }
    }
}

tasks {
    register("iosTest") {
        val device = project.findProperty("device")?.toString() ?: "iPhone 8"
        dependsOn("linkDebugTestIosX64")
        group = JavaBasePlugin.VERIFICATION_GROUP
        description = "Execute unit tests on ${device} simulator"
        doLast {
            val binary = kotlin.targets.getByName("iosX64").binaries.getTest("DEBUG")
            exec {
                commandLine("xcrun", "simctl", "spawn", device, binary.outputFile)
            }
        }
    }
    register("test") {
        dependsOn("allTests")
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy