blob: 6c4e700f369653c38b2b4a8dee96db66c0b30c4d [file] [log] [blame]
Vsevolod Tolstopyatovf3195b62019-12-27 12:38:39 +03001/*
Leonid Startsev71c08cc2020-01-24 14:41:56 +03002 * Copyright 2017-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
Vsevolod Tolstopyatovf3195b62019-12-27 12:38:39 +03003 */
Leonid Startsev3fecf302019-04-04 15:42:55 +03004buildscript {
5 ext.serialization_version = mainLibVersion
6
7 repositories {
8 mavenCentral()
Leonid Startsevfc9343f2021-04-26 15:18:02 +03009 maven { url "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" }
Clara Fok93e18122024-04-23 10:28:10 -070010 mavenLocal() {
11 mavenContent {
12 snapshotsOnly()
13 }
14 }
Leonid Startsev3fecf302019-04-04 15:42:55 +030015 }
Leonid Startsev3fecf302019-04-04 15:42:55 +030016}
17
Clara Fok93e18122024-04-23 10:28:10 -070018// Versions substituted in settings.gradle
Leonid Startsev3fecf302019-04-04 15:42:55 +030019plugins {
Clara Fok93e18122024-04-23 10:28:10 -070020 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 Startsev3fecf302019-04-04 15:42:55 +030023}
24
25repositories {
Leonid Startsev3fecf302019-04-04 15:42:55 +030026 mavenCentral()
Leonid Startsevfc9343f2021-04-26 15:18:02 +030027 maven { url "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" }
Clara Fok93e18122024-04-23 10:28:10 -070028 mavenLocal() {
29 mavenContent {
30 snapshotsOnly()
31 }
32 }
Leonid Startsev3fecf302019-04-04 15:42:55 +030033}
34
35group 'com.example'
36version '0.0.1'
37
38apply plugin: 'maven-publish'
39
40kotlin {
Leonid Startsev3fecf302019-04-04 15:42:55 +030041 // Switching module kind for JS is required to run tests
Leonid Startsev7e526a82020-09-15 15:49:46 +030042 js {
43 nodejs {}
44 configure([compilations.main, compilations.test]) {
45 kotlinOptions {
46 sourceMap = true
47 moduleKind = "umd"
Leonid Startsev3fecf302019-04-04 15:42:55 +030048 }
49 }
50 }
Clara Fok93e18122024-04-23 10:28:10 -070051 wasmJs {
52 nodejs()
53 }
54 wasmWasi {
55 nodejs()
56 }
Leonid Startsevff0a6bc2020-07-23 20:24:43 +030057 jvm {
58 withJava()
59 }
Clara Fok93e18122024-04-23 10:28:10 -070060 macosX64()
61 macosArm64()
62 linuxX64()
63 mingwX64()
64
Leonid Startsev3fecf302019-04-04 15:42:55 +030065 sourceSets {
Clara Fok93e18122024-04-23 10:28:10 -070066 all {
67 languageSettings {
68 optIn('kotlinx.serialization.ExperimentalSerializationApi')
69 }
70 }
71
Leonid Startsev3fecf302019-04-04 15:42:55 +030072 commonMain {
73 dependencies {
Clara Fok93e18122024-04-23 10:28:10 -070074 implementation kotlin('stdlib')
Leonid Startseva1482602020-08-03 14:40:25 +030075 implementation "org.jetbrains.kotlinx:kotlinx-serialization-core:$serialization_version"
Vsevolod Tolstopyatov0e4e0e72020-09-14 04:04:34 -070076 implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$serialization_version"
Sergey Igushkinc5f1af62020-05-26 15:54:39 +030077 implementation "org.jetbrains.kotlinx:kotlinx-serialization-protobuf:$serialization_version"
78 implementation "org.jetbrains.kotlinx:kotlinx-serialization-cbor:$serialization_version"
Leonid Startsev3fecf302019-04-04 15:42:55 +030079 }
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 Startsev0e19a272019-04-15 18:22:18 +030090 implementation 'com.google.dagger:dagger:2.13'
Leonid Startsev3fecf302019-04-04 15:42:55 +030091 }
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 Tolstopyatovf3195b62019-12-27 12:38:39 +0300102
Leonid Startsev3fecf302019-04-04 15:42:55 +0300103 }
104 }
105 jsTest {
106 dependencies {
107 implementation kotlin('test-js')
108 }
109 }
Clara Fok93e18122024-04-23 10:28:10 -0700110 wasmJsMain {
Leonid Startsev71c08cc2020-01-24 14:41:56 +0300111 dependencies {
Clara Fok93e18122024-04-23 10:28:10 -0700112 api 'org.jetbrains.kotlin:kotlin-stdlib-wasm-js'
Leonid Startsev71c08cc2020-01-24 14:41:56 +0300113 }
114 }
Clara Fok93e18122024-04-23 10:28:10 -0700115 wasmJsTest {
116 dependencies {
117 api 'org.jetbrains.kotlin:kotlin-test-wasm-js'
118 }
Leonid Startsev71c08cc2020-01-24 14:41:56 +0300119 }
Clara Fok93e18122024-04-23 10:28:10 -0700120 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 Startsev71c08cc2020-01-24 14:41:56 +0300129 }
Leonid Startsev3fecf302019-04-04 15:42:55 +0300130 }
Clara Fok93e18122024-04-23 10:28:10 -0700131
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 Startsev0e19a272019-04-15 18:22:18 +0300142 }
143 }
144}
145
146dependencies {
147 kapt 'com.google.dagger:dagger-compiler:2.13'
Leonid Startsev3fecf302019-04-04 15:42:55 +0300148}
149
Leonid Startsev3fecf302019-04-04 15:42:55 +0300150task run dependsOn "check"
Clara Fok93e18122024-04-23 10:28:10 -0700151
152rootProject.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
158tasks.withType(org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask).configureEach {
159 args.add("--ignore-engines")
160}