summaryrefslogtreecommitdiff
path: root/runtime/build.gradle
blob: 0bb0712db0fab313f78a280594e485d145347d1b (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*
 * Copyright 2017-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
 */
apply plugin: 'java' // Needed for protobuf plugin only

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

ext {
    jacksonVersion = '2.9.1'
}

// Protobuf plugin used in tests

apply plugin: 'com.google.protobuf'

protobuf {
    protoc {
        // Download from repositories
        artifact = 'com.google.protobuf:protoc:3.0.0'
    }
}

clean {
    delete protobuf.generatedFilesBaseDir
}

def deployMode = property('native.deploy') == 'true'

kotlin {
    infra {
        target('macosX64')
        target('linuxX64')
        if (deployMode) {
            target('mingwX64')
            target('iosArm64')
            target('iosArm32')
            target('iosX64')
        }
    }

    targets {
        fromPreset(presets.jvmWithJava, 'jvm') {
            configure([compilations.main, compilations.test]) {
                kotlinOptions {
                    jvmTarget = '1.6'
                }
            }
        }
        fromPreset(presets.js, 'js') {
            configure([compilations.main, compilations.test]) {
                kotlinOptions {
                    sourceMap = true
                    moduleKind = "umd"
                    metaInfo = true
                }
            }
        }
    }

    sourceSets.all {
        kotlin.srcDirs = ["$it.name/src"]
        resources.srcDirs = ["$it.name/resources"]
        languageSettings {
            progressiveMode = true
            useExperimentalAnnotation("kotlin.Experimental")
            useExperimentalAnnotation("kotlin.ExperimentalMultiplatform")
        }
    }

    sourceSets {
        commonMain {
            dependencies {
                api "org.jetbrains.kotlin:kotlin-stdlib"
            }
        }

        commonTest {
            dependencies {
                api 'org.jetbrains.kotlin:kotlin-test-common'
            }
        }

        jvmJsTest {
            dependsOn commonTest

            dependencies {
                api 'org.jetbrains.kotlin:kotlin-test-common'
                api 'org.jetbrains.kotlin:kotlin-test-annotations-common'
            }
        }

        jvmMain {
            dependencies {
                api 'org.jetbrains.kotlin:kotlin-stdlib'
            }
        }
        jvmTest {
            dependsOn jvmJsTest

            kotlin.srcDirs += file("${protobuf.generatedFilesBaseDir}/test/java")

            dependencies {
                api 'org.jetbrains.kotlin:kotlin-test-junit'
                implementation 'io.kotlintest:kotlintest:2.0.4'

                implementation 'com.google.protobuf:protobuf-java:3.0.0'
                implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: jacksonVersion
                implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: jacksonVersion
                implementation group: 'com.fasterxml.jackson.module', name: 'jackson-module-kotlin', version: jacksonVersion
                implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-cbor', version: jacksonVersion
                implementation group: 'com.google.code.gson', name: 'gson', version: '2.7'
            }
        }

        jsMain {
            dependencies {
                api 'org.jetbrains.kotlin:kotlin-stdlib-js'
            }
        }

        jsTest {
            dependsOn jvmJsTest

            dependencies {
                api 'org.jetbrains.kotlin:kotlin-test-js'
            }
        }

        nativeMain.dependencies {
        }
    }

    sourceSets.findAll({ it.name.contains("Test") }).forEach { srcSet ->
        srcSet.languageSettings {
            it.useExperimentalAnnotation("kotlinx.serialization.UnstableDefault")

            if (srcSet.name.contains("jvm") || srcSet.name.contains("js")) {
                it.useExperimentalAnnotation("kotlinx.serialization.ImplicitReflectionSerializer")
            }
        }
    }
}

sourceSets.test.proto {
    srcDirs = ['testProto']
}

compileTestKotlinJvm {
    dependsOn 'generateTestProto'
}