summaryrefslogtreecommitdiff
path: root/core/build.gradle
blob: f52837acb36c843034035017b26d7779e1ca8b41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile

/*
 * Copyright 2017-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
 */

apply plugin: 'kotlin-multiplatform'
apply plugin: 'kotlinx-serialization'

apply from: rootProject.file("gradle/native-targets.gradle")
apply from: rootProject.file("gradle/configure-source-sets.gradle")

kotlin {
    sourceSets {
        jvmTest {
            dependencies {
                implementation 'io.kotlintest:kotlintest:2.0.7'
                implementation 'com.google.guava:guava:24.1.1-jre'
                implementation 'com.google.code.gson:gson:2.8.5'
                implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
            }
        }
    }
}

/*
 These manifest values help kotlinx.serialization compiler plugin determine if it is compatible with a given runtime library.
 Plugin reads them during compilation.

 Implementation-Version is used to determine whether runtime library supports a given plugin feature (e.g. value classes serialization
 in Kotlin 1.x may require runtime library version 1.y to work).
 Compiler plugin may enable or disable features by looking on Implementation-Version.

 Require-Kotlin-Version is used to determine whether runtime library with new features can work with old compilers.
 In ideal case, its value should always be 1.4, but some refactorings (e.g. adding a method to the Encoder interface)
 may unexpectedly break old compilers, so it is left out as a safety net. Compiler plugins, starting from 1.4 are instructed
 to reject runtime if runtime's Require-Kotlin-Version is greater then the current compiler.
 */
tasks.withType(Jar).named(kotlin.jvm().artifactsTaskName) {

    // adding the ProGuard rules to the jar
    from(rootProject.file("rules/common.pro")) {
        rename { "kotlinx-serialization-common.pro" }
        into("META-INF/proguard")
    }
    from(rootProject.file("rules/common.pro")) {
        rename { "kotlinx-serialization-common.pro" }
        into("META-INF/com.android.tools/proguard")
    }
    from(rootProject.file("rules/common.pro")) {
        rename { "kotlinx-serialization-common.pro" }
        into("META-INF/com.android.tools/r8")
    }
    from(rootProject.file("rules/r8.pro")) {
        rename { "kotlinx-serialization-r8.pro" }
        into("META-INF/com.android.tools/r8")
    }


    manifest {
        attributes(
                "Implementation-Version": version,
                "Require-Kotlin-Version": "1.4.30-M1",
        )
    }
}

Java9Modularity.configureJava9ModuleInfo(project)

tasks.withType(org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrLink.class).configureEach {
    kotlinOptions.freeCompilerArgs += "-Xwasm-enable-array-range-checks"
}