Vsevolod Tolstopyatov | f3195b6 | 2019-12-27 12:38:39 +0300 | [diff] [blame] | 1 | /* |
Leonid Startsev | 71c08cc | 2020-01-24 14:41:56 +0300 | [diff] [blame] | 2 | * Copyright 2017-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. |
Vsevolod Tolstopyatov | f3195b6 | 2019-12-27 12:38:39 +0300 | [diff] [blame] | 3 | */ |
Leonid Startsev | 3fecf30 | 2019-04-04 15:42:55 +0300 | [diff] [blame] | 4 | buildscript { |
| 5 | ext.serialization_version = mainLibVersion |
| 6 | |
| 7 | repositories { |
| 8 | mavenCentral() |
Leonid Startsev | fc9343f | 2021-04-26 15:18:02 +0300 | [diff] [blame] | 9 | maven { url "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" } |
Clara Fok | 93e1812 | 2024-04-23 10:28:10 -0700 | [diff] [blame] | 10 | mavenLocal() { |
| 11 | mavenContent { |
| 12 | snapshotsOnly() |
| 13 | } |
| 14 | } |
Leonid Startsev | 3fecf30 | 2019-04-04 15:42:55 +0300 | [diff] [blame] | 15 | } |
Leonid Startsev | 3fecf30 | 2019-04-04 15:42:55 +0300 | [diff] [blame] | 16 | } |
| 17 | |
Clara Fok | 93e1812 | 2024-04-23 10:28:10 -0700 | [diff] [blame] | 18 | // Versions substituted in settings.gradle |
Leonid Startsev | 3fecf30 | 2019-04-04 15:42:55 +0300 | [diff] [blame] | 19 | plugins { |
Clara Fok | 93e1812 | 2024-04-23 10:28:10 -0700 | [diff] [blame] | 20 | id 'org.jetbrains.kotlin.multiplatform' version '0' |
| 21 | id 'org.jetbrains.kotlin.plugin.serialization' version '0' |
| 22 | id 'org.jetbrains.kotlin.kapt' version '0' |
Leonid Startsev | 3fecf30 | 2019-04-04 15:42:55 +0300 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | repositories { |
Leonid Startsev | 3fecf30 | 2019-04-04 15:42:55 +0300 | [diff] [blame] | 26 | mavenCentral() |
Leonid Startsev | fc9343f | 2021-04-26 15:18:02 +0300 | [diff] [blame] | 27 | maven { url "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" } |
Clara Fok | 93e1812 | 2024-04-23 10:28:10 -0700 | [diff] [blame] | 28 | mavenLocal() { |
| 29 | mavenContent { |
| 30 | snapshotsOnly() |
| 31 | } |
| 32 | } |
Leonid Startsev | 3fecf30 | 2019-04-04 15:42:55 +0300 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | group 'com.example' |
| 36 | version '0.0.1' |
| 37 | |
| 38 | apply plugin: 'maven-publish' |
| 39 | |
| 40 | kotlin { |
Leonid Startsev | 3fecf30 | 2019-04-04 15:42:55 +0300 | [diff] [blame] | 41 | // Switching module kind for JS is required to run tests |
Leonid Startsev | 7e526a8 | 2020-09-15 15:49:46 +0300 | [diff] [blame] | 42 | js { |
| 43 | nodejs {} |
| 44 | configure([compilations.main, compilations.test]) { |
| 45 | kotlinOptions { |
| 46 | sourceMap = true |
| 47 | moduleKind = "umd" |
Leonid Startsev | 3fecf30 | 2019-04-04 15:42:55 +0300 | [diff] [blame] | 48 | } |
| 49 | } |
| 50 | } |
Clara Fok | 93e1812 | 2024-04-23 10:28:10 -0700 | [diff] [blame] | 51 | wasmJs { |
| 52 | nodejs() |
| 53 | } |
| 54 | wasmWasi { |
| 55 | nodejs() |
| 56 | } |
Leonid Startsev | ff0a6bc | 2020-07-23 20:24:43 +0300 | [diff] [blame] | 57 | jvm { |
| 58 | withJava() |
| 59 | } |
Clara Fok | 93e1812 | 2024-04-23 10:28:10 -0700 | [diff] [blame] | 60 | macosX64() |
| 61 | macosArm64() |
| 62 | linuxX64() |
| 63 | mingwX64() |
| 64 | |
Leonid Startsev | 3fecf30 | 2019-04-04 15:42:55 +0300 | [diff] [blame] | 65 | sourceSets { |
Clara Fok | 93e1812 | 2024-04-23 10:28:10 -0700 | [diff] [blame] | 66 | all { |
| 67 | languageSettings { |
| 68 | optIn('kotlinx.serialization.ExperimentalSerializationApi') |
| 69 | } |
| 70 | } |
| 71 | |
Leonid Startsev | 3fecf30 | 2019-04-04 15:42:55 +0300 | [diff] [blame] | 72 | commonMain { |
| 73 | dependencies { |
Clara Fok | 93e1812 | 2024-04-23 10:28:10 -0700 | [diff] [blame] | 74 | implementation kotlin('stdlib') |
Leonid Startsev | a148260 | 2020-08-03 14:40:25 +0300 | [diff] [blame] | 75 | implementation "org.jetbrains.kotlinx:kotlinx-serialization-core:$serialization_version" |
Vsevolod Tolstopyatov | 0e4e0e7 | 2020-09-14 04:04:34 -0700 | [diff] [blame] | 76 | implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$serialization_version" |
Sergey Igushkin | c5f1af6 | 2020-05-26 15:54:39 +0300 | [diff] [blame] | 77 | implementation "org.jetbrains.kotlinx:kotlinx-serialization-protobuf:$serialization_version" |
| 78 | implementation "org.jetbrains.kotlinx:kotlinx-serialization-cbor:$serialization_version" |
Leonid Startsev | 3fecf30 | 2019-04-04 15:42:55 +0300 | [diff] [blame] | 79 | } |
| 80 | } |
| 81 | commonTest { |
| 82 | dependencies { |
| 83 | implementation kotlin('test-common') |
| 84 | implementation kotlin('test-annotations-common') |
| 85 | } |
| 86 | } |
| 87 | jvmMain { |
| 88 | dependencies { |
| 89 | implementation kotlin('stdlib-jdk8') |
Leonid Startsev | 0e19a27 | 2019-04-15 18:22:18 +0300 | [diff] [blame] | 90 | implementation 'com.google.dagger:dagger:2.13' |
Leonid Startsev | 3fecf30 | 2019-04-04 15:42:55 +0300 | [diff] [blame] | 91 | } |
| 92 | } |
| 93 | jvmTest { |
| 94 | dependencies { |
| 95 | implementation kotlin('test') |
| 96 | implementation kotlin('test-junit') |
| 97 | } |
| 98 | } |
| 99 | jsMain { |
| 100 | dependencies { |
| 101 | implementation kotlin('stdlib-js') |
Vsevolod Tolstopyatov | f3195b6 | 2019-12-27 12:38:39 +0300 | [diff] [blame] | 102 | |
Leonid Startsev | 3fecf30 | 2019-04-04 15:42:55 +0300 | [diff] [blame] | 103 | } |
| 104 | } |
| 105 | jsTest { |
| 106 | dependencies { |
| 107 | implementation kotlin('test-js') |
| 108 | } |
| 109 | } |
Clara Fok | 93e1812 | 2024-04-23 10:28:10 -0700 | [diff] [blame] | 110 | wasmJsMain { |
Leonid Startsev | 71c08cc | 2020-01-24 14:41:56 +0300 | [diff] [blame] | 111 | dependencies { |
Clara Fok | 93e1812 | 2024-04-23 10:28:10 -0700 | [diff] [blame] | 112 | api 'org.jetbrains.kotlin:kotlin-stdlib-wasm-js' |
Leonid Startsev | 71c08cc | 2020-01-24 14:41:56 +0300 | [diff] [blame] | 113 | } |
| 114 | } |
Clara Fok | 93e1812 | 2024-04-23 10:28:10 -0700 | [diff] [blame] | 115 | wasmJsTest { |
| 116 | dependencies { |
| 117 | api 'org.jetbrains.kotlin:kotlin-test-wasm-js' |
| 118 | } |
Leonid Startsev | 71c08cc | 2020-01-24 14:41:56 +0300 | [diff] [blame] | 119 | } |
Clara Fok | 93e1812 | 2024-04-23 10:28:10 -0700 | [diff] [blame] | 120 | wasmWasiMain { |
| 121 | dependencies { |
| 122 | api 'org.jetbrains.kotlin:kotlin-stdlib-wasm-wasi' |
| 123 | } |
| 124 | } |
| 125 | wasmWasiTest { |
| 126 | dependencies { |
| 127 | api 'org.jetbrains.kotlin:kotlin-test-wasm-wasi' |
| 128 | } |
Leonid Startsev | 71c08cc | 2020-01-24 14:41:56 +0300 | [diff] [blame] | 129 | } |
Leonid Startsev | 3fecf30 | 2019-04-04 15:42:55 +0300 | [diff] [blame] | 130 | } |
Clara Fok | 93e1812 | 2024-04-23 10:28:10 -0700 | [diff] [blame] | 131 | |
| 132 | targets.all { |
| 133 | compilations.all { |
| 134 | kotlinOptions { |
| 135 | freeCompilerArgs += "-Xexpect-actual-classes" |
| 136 | } |
| 137 | } |
| 138 | compilations.main { |
| 139 | kotlinOptions { |
| 140 | allWarningsAsErrors = true |
| 141 | } |
Leonid Startsev | 0e19a27 | 2019-04-15 18:22:18 +0300 | [diff] [blame] | 142 | } |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | dependencies { |
| 147 | kapt 'com.google.dagger:dagger-compiler:2.13' |
Leonid Startsev | 3fecf30 | 2019-04-04 15:42:55 +0300 | [diff] [blame] | 148 | } |
| 149 | |
Leonid Startsev | 3fecf30 | 2019-04-04 15:42:55 +0300 | [diff] [blame] | 150 | task run dependsOn "check" |
Clara Fok | 93e1812 | 2024-04-23 10:28:10 -0700 | [diff] [blame] | 151 | |
| 152 | rootProject.extensions.findByType(org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension.class).with { |
| 153 | // canary nodejs that supports recent Wasm GC changes |
| 154 | it.nodeVersion = "21.0.0-v8-canary202309167e82ab1fa2" |
| 155 | it.nodeDownloadBaseUrl = "https://nodejs.org/download/v8-canary" |
| 156 | } |
| 157 | |
| 158 | tasks.withType(org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask).configureEach { |
| 159 | args.add("--ignore-engines") |
| 160 | } |