-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
kotlin-multiplatform-conventions.gradle.kts
139 lines (132 loc) · 4.28 KB
/
kotlin-multiplatform-conventions.gradle.kts
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
/*
* Copyright 2016-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
import org.gradle.api.*
import org.gradle.api.tasks.testing.logging.*
import org.jetbrains.kotlin.gradle.dsl.*
plugins {
kotlin("multiplatform")
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlin {
jvm {
compilations.all {
compilerOptions.configure {
jvmTarget = JvmTarget.JVM_1_8
}
}
}
jvmToolchain(jdkToolchainVersion)
if (nativeTargetsAreEnabled) {
// According to https://kotlinlang.org/docs/native-target-support.html
// Tier 1
linuxX64()
macosX64()
macosArm64()
iosSimulatorArm64()
iosX64()
// Tier 2
linuxArm64()
watchosSimulatorArm64()
watchosX64()
watchosArm32()
watchosArm64()
tvosSimulatorArm64()
tvosX64()
tvosArm64()
iosArm64()
// Tier 3
androidNativeArm32()
androidNativeArm64()
androidNativeX86()
androidNativeX64()
mingwX64()
watchosDeviceArm64()
}
js {
moduleName = project.name
nodejs()
compilations["main"]?.dependencies {
api("org.jetbrains.kotlinx:atomicfu-js:${version("atomicfu")}")
}
}
@OptIn(org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl::class)
wasmJs {
// Module name should be different from the one from JS
// otherwise IC tasks that start clashing different modules with the same module name
moduleName = project.name + "Wasm"
nodejs()
compilations["main"]?.dependencies {
api("org.jetbrains.kotlinx:atomicfu-wasm-js:${version("atomicfu")}")
}
}
applyDefaultHierarchyTemplate()
sourceSets {
commonTest {
dependencies {
api("org.jetbrains.kotlin:kotlin-test-common:${version("kotlin")}")
api("org.jetbrains.kotlin:kotlin-test-annotations-common:${version("kotlin")}")
}
}
jvmMain.dependencies {
compileOnly("org.codehaus.mojo:animal-sniffer-annotations:1.20")
// Workaround until https://github.com/JetBrains/kotlin/pull/4999 is picked up
api("org.jetbrains:annotations:23.0.0")
}
jvmTest.dependencies {
api("org.jetbrains.kotlin:kotlin-test:${version("kotlin")}")
// Workaround to make addSuppressed work in tests
api("org.jetbrains.kotlin:kotlin-reflect:${version("kotlin")}")
api("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${version("kotlin")}")
api("org.jetbrains.kotlin:kotlin-test-junit:${version("kotlin")}")
api("junit:junit:${version("junit")}")
}
nativeMain.dependencies {
// workaround for #3968 until this is fixed on atomicfu's side
api("org.jetbrains.kotlinx:atomicfu:0.23.1")
}
val jsAndWasmSharedMain by registering {
dependsOn(commonMain.get())
}
val jsAndWasmSharedTest by registering {
dependsOn(commonTest.get())
}
jsMain {
dependsOn(jsAndWasmSharedMain.get())
}
jsTest {
dependsOn(jsAndWasmSharedTest.get())
dependencies {
api("org.jetbrains.kotlin:kotlin-test-js:${version("kotlin")}")
}
}
val wasmJsMain by getting {
dependsOn(jsAndWasmSharedMain.get())
}
val wasmJsTest by getting {
dependsOn(jsAndWasmSharedTest.get())
dependencies {
api("org.jetbrains.kotlin:kotlin-test-wasm-js:${version("kotlin")}")
}
}
}
}
// Disable intermediate sourceSet compilation because we do not need js-wasmJs artifact
tasks.configureEach {
if (name == "compileJsAndWasmSharedMainKotlinMetadata") {
enabled = false
}
}
tasks.named("jvmTest", Test::class) {
testLogging {
showStandardStreams = true
events = setOf(TestLogEvent.PASSED, TestLogEvent.FAILED)
}
val stressTest = project.properties["stressTest"]
if (stressTest != null) {
systemProperty("stressTest", "stressTest")
}
}