|
| 1 | +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget |
| 2 | + |
| 3 | +plugins { |
| 4 | + kotlin("multiplatform") version "2.2.20" // kotlin_version |
| 5 | + kotlin("plugin.serialization") version "2.2.20" // kotlin_version |
| 6 | +} |
| 7 | + |
| 8 | +group = "org.openapitools" |
| 9 | +version = "1.0.0" |
| 10 | + |
| 11 | +val kotlin_version = "2.2.20" |
| 12 | +val coroutines_version = "1.10.2" |
| 13 | +val serialization_version = "1.9.0" |
| 14 | +val ktor_version = "3.2.3" |
| 15 | + |
| 16 | +repositories { |
| 17 | + mavenCentral() |
| 18 | +} |
| 19 | + |
| 20 | +kotlin { |
| 21 | + jvm() |
| 22 | + iosX64() |
| 23 | + iosArm64() |
| 24 | + iosSimulatorArm64() |
| 25 | + js { |
| 26 | + browser() |
| 27 | + nodejs() |
| 28 | + } |
| 29 | + |
| 30 | + sourceSets { |
| 31 | + commonMain { |
| 32 | + dependencies { |
| 33 | + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version") |
| 34 | + implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:$serialization_version") |
| 35 | + |
| 36 | + api("io.ktor:ktor-client-core:$ktor_version") |
| 37 | + api("io.ktor:ktor-client-serialization:$ktor_version") |
| 38 | + api("io.ktor:ktor-client-content-negotiation:$ktor_version") |
| 39 | + api("io.ktor:ktor-serialization-kotlinx-json:$ktor_version") |
| 40 | + |
| 41 | + api("org.jetbrains.kotlinx:kotlinx-datetime:0.7.1") |
| 42 | + } |
| 43 | + } |
| 44 | + |
| 45 | + commonTest { |
| 46 | + dependencies { |
| 47 | + implementation(kotlin("test")) |
| 48 | + implementation("io.ktor:ktor-client-mock:$ktor_version") |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + jvmMain { |
| 53 | + dependencies { |
| 54 | + implementation(kotlin("stdlib-jdk7")) |
| 55 | + implementation("io.ktor:ktor-client-cio-jvm:$ktor_version") |
| 56 | + } |
| 57 | + } |
| 58 | + |
| 59 | + jvmTest { |
| 60 | + dependencies { |
| 61 | + implementation(kotlin("test-junit")) |
| 62 | + } |
| 63 | + } |
| 64 | + |
| 65 | + iosMain { |
| 66 | + dependencies { |
| 67 | + api("io.ktor:ktor-client-ios:$ktor_version") |
| 68 | + } |
| 69 | + } |
| 70 | + |
| 71 | + jsMain { |
| 72 | + dependencies { |
| 73 | + api("io.ktor:ktor-client-js:$ktor_version") |
| 74 | + } |
| 75 | + } |
| 76 | + |
| 77 | + all { |
| 78 | + languageSettings { |
| 79 | + optIn("kotlin.time.ExperimentalTime") |
| 80 | + } |
| 81 | + } |
| 82 | + } |
| 83 | +} |
| 84 | + |
| 85 | +tasks { |
| 86 | + register<Exec>("iosTest") { |
| 87 | + val device = project.findProperty("device")?.toString() ?: "iPhone 8" |
| 88 | + dependsOn("linkDebugTestIosX64") |
| 89 | + group = JavaBasePlugin.VERIFICATION_GROUP |
| 90 | + description = "Execute unit tests on ${device} simulator" |
| 91 | + val binary = kotlin.targets.getByName<KotlinNativeTarget>("iosX64").binaries.getTest("DEBUG") |
| 92 | + commandLine("xcrun", "simctl", "spawn", device, binary.outputFile) |
| 93 | + } |
| 94 | + register("test") { |
| 95 | + dependsOn("allTests") |
| 96 | + } |
| 97 | +} |
0 commit comments