1import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile 2 3/* 4 * Copyright 2017-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. 5 */ 6 7apply plugin: 'kotlin-multiplatform' 8apply plugin: 'kotlinx-serialization' 9 10apply from: rootProject.file("gradle/native-targets.gradle") 11apply from: rootProject.file("gradle/configure-source-sets.gradle") 12 13kotlin { 14 sourceSets { 15 jvmTest { 16 dependencies { 17 implementation 'io.kotlintest:kotlintest:2.0.7' 18 implementation 'com.google.guava:guava:24.1.1-jre' 19 implementation 'com.google.code.gson:gson:2.8.5' 20 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" 21 } 22 } 23 } 24} 25 26/* 27 These manifest values help kotlinx.serialization compiler plugin determine if it is compatible with a given runtime library. 28 Plugin reads them during compilation. 29 30 Implementation-Version is used to determine whether runtime library supports a given plugin feature (e.g. value classes serialization 31 in Kotlin 1.x may require runtime library version 1.y to work). 32 Compiler plugin may enable or disable features by looking on Implementation-Version. 33 34 Require-Kotlin-Version is used to determine whether runtime library with new features can work with old compilers. 35 In ideal case, its value should always be 1.4, but some refactorings (e.g. adding a method to the Encoder interface) 36 may unexpectedly break old compilers, so it is left out as a safety net. Compiler plugins, starting from 1.4 are instructed 37 to reject runtime if runtime's Require-Kotlin-Version is greater then the current compiler. 38 */ 39tasks.withType(Jar).named(kotlin.jvm().artifactsTaskName) { 40 41 // adding the ProGuard rules to the jar 42 from(rootProject.file("rules/common.pro")) { 43 rename { "kotlinx-serialization-common.pro" } 44 into("META-INF/proguard") 45 } 46 from(rootProject.file("rules/common.pro")) { 47 rename { "kotlinx-serialization-common.pro" } 48 into("META-INF/com.android.tools/proguard") 49 } 50 from(rootProject.file("rules/common.pro")) { 51 rename { "kotlinx-serialization-common.pro" } 52 into("META-INF/com.android.tools/r8") 53 } 54 from(rootProject.file("rules/r8.pro")) { 55 rename { "kotlinx-serialization-r8.pro" } 56 into("META-INF/com.android.tools/r8") 57 } 58 59 60 manifest { 61 attributes( 62 "Implementation-Version": version, 63 "Require-Kotlin-Version": "1.4.30-M1", 64 ) 65 } 66} 67 68Java9Modularity.configureJava9ModuleInfo(project) 69 70tasks.withType(org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrLink.class).configureEach { 71 kotlinOptions.freeCompilerArgs += "-Xwasm-enable-array-range-checks" 72} 73