This repository has been archived by the owner on Feb 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
build.gradle.kts
177 lines (157 loc) · 4.47 KB
/
build.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMetadataTarget
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget
import org.jetbrains.kotlin.konan.target.HostManager
val coroutinesVersion = "1.6.0"
val atomicfuVersion = "0.17.0"
plugins {
kotlin("multiplatform") version "1.7.10"
id("org.jetbrains.dokka") version "0.10.0"
id("maven-publish")
id("signing")
}
repositories {
google()
jcenter()
mavenCentral()
}
kotlin {
explicitApi()
targets {
jvm {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
js(BOTH) {
compilations.all {
kotlinOptions {
moduleKind = "commonjs"
}
}
browser()
nodejs()
}
}
iosX64()
iosArm64()
iosArm32()
iosSimulatorArm64()
macosArm64()
macosX64()
tvosArm64()
tvosSimulatorArm64()
tvosX64()
watchosArm32()
watchosArm64()
watchosSimulatorArm64()
// waiting on https://github.com/Kotlin/kotlinx.coroutines/pull/2679
//watchosX64()
watchosX86()
mingwX64()
linuxX64()
targets.withType<KotlinNativeTarget> {
val main by compilations.getting {
kotlinOptions.freeCompilerArgs = listOf("-Xopt-in=kotlin.RequiresOptIn")
}
}
targets.withType<KotlinJsTarget> {
val test by compilations.getting {
kotlinOptions.freeCompilerArgs = listOf("-Xopt-in=kotlin.RequiresOptIn")
}
}
// do this in afterEvaluate, when nativeMain compilation becomes available
afterEvaluate {
targets.withType<KotlinMetadataTarget> {
for (compilation in compilations) {
if (compilation.name == "nativeMain") {
compilation.kotlinOptions.freeCompilerArgs = listOf("-Xopt-in=kotlin.RequiresOptIn")
}
}
}
}
sourceSets {
val commonMain by getting {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
implementation("org.jetbrains.kotlinx:atomicfu:$atomicfuVersion")
}
}
val nativeMain by creating {
dependsOn(commonMain)
}
val nativeTest by creating {
dependsOn(commonTest)
}
val appleMain by creating
val appleTargets = listOf(
"iosX64",
"iosArm64",
"iosArm32",
"iosSimulatorArm64",
"macosArm64",
"macosX64",
"tvosArm64",
"tvosSimulatorArm64",
"tvosX64",
"watchosArm32",
"watchosArm64",
"watchosSimulatorArm64",
"watchosX86"
// waiting on https://github.com/Kotlin/kotlinx.coroutines/pull/2679
//"watchosX64"
)
appleTargets.forEach {
getByName("${it}Main") {
dependsOn(appleMain)
}
}
(appleTargets + listOf("mingwX64", "linuxX64")).forEach {
getByName("${it}Main") {
dependsOn(nativeMain)
}
getByName("${it}Test") {
dependsOn(nativeTest)
}
}
}
}
kotlin {
targets.all {
compilations.all {
// https://youtrack.jetbrains.com/issue/KT-46257
kotlinOptions.allWarningsAsErrors = false
}
}
}
val ktlintConfig by configurations.creating
dependencies {
ktlintConfig("com.pinterest:ktlint:0.41.0")
}
val ktlint by tasks.registering(JavaExec::class) {
group = "verification"
description = "Check Kotlin code style."
classpath = ktlintConfig
main = "com.pinterest.ktlint.Main"
args = listOf("src/**/*.kt")
}
val ktlintformat by tasks.registering(JavaExec::class) {
group = "formatting"
description = "Fix Kotlin code style deviations."
classpath = ktlintConfig
main = "com.pinterest.ktlint.Main"
args = listOf("-F", "src/**/*.kt", "*.kts")
}
val checkTask = tasks.named("check")
checkTask.configure {
dependsOn(ktlint)
}
apply("publish.gradle")