-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.gradle.kts
198 lines (182 loc) · 5.46 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension
import java.time.Duration
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
alias(libs.plugins.multiplatform)
alias(libs.plugins.serialization)
alias(libs.plugins.dokka)
alias(libs.plugins.binaryCompat)
alias(libs.plugins.spotless)
alias(libs.plugins.mavenPublish)
}
buildscript {
repositories {
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath(libs.atomicfu.plugin)
}
}
allprojects {
repositories {
mavenCentral()
}
}
apply(plugin = "kotlinx-atomicfu")
plugins.withType<NodeJsRootPlugin> {
the<YarnRootExtension>().lockFileDirectory = rootDir.resolve("gradle/kotlin-js-store")
}
version = System.getenv("GITHUB_REF")?.substringAfter("refs/tags/v", version.toString()) ?: version
val testGenSrcPath = "build/test-gen/config"
val installTestConfig by tasks.creating {
val configFile = file("${testGenSrcPath}/config.kt")
onlyIf { !configFile.exists() || gradle.startParameter.taskNames.contains("publish") }
doFirst {
file(testGenSrcPath).mkdirs()
if (!configFile.exists()) {
val demoKey = System.getProperty("demoApiKey")?.toString().orEmpty()
configFile.writeText(
"""|package coingecko
|
|val DEMO_API_KEY = "$demoKey"
|""".trimMargin(),
)
}
}
}
kotlin {
jvm()
js(IR) {
browser {
testTask {
useKarma {
useFirefoxHeadless()
timeout.set(Duration.ofSeconds(30))
}
}
}
nodejs {
testTask {
useMocha {
timeout = "30000"
}
}
}
}
macosX64()
macosArm64()
mingwX64("win64")
linuxX64()
iosArm64()
iosX64()
iosSimulatorArm64()
watchosArm32()
watchosArm64()
tvosArm64()
tvosSimulatorArm64()
tvosX64()
applyDefaultHierarchyTemplate()
targets.all {
compilations
.filter { it.name.endsWith("test", ignoreCase = true) }
.forEach {
it.compileTaskProvider.configure {
dependsOn(installTestConfig)
}
}
}
sourceSets {
val commonMain by getting {
dependencies {
implementation(kotlin("stdlib-common"))
implementation(libs.coroutines.core)
implementation(libs.serialization.json)
implementation(libs.ktor.client.core)
implementation(libs.ktor.client.contentNegotiation)
implementation(libs.ktor.serialization)
implementation(libs.atomicfu)
}
}
val commonTest by getting {
kotlin.srcDirs(testGenSrcPath)
dependencies {
implementation(libs.coroutines.test)
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val jvmMain by getting {
dependencies {
implementation(kotlin("stdlib-jdk8"))
}
}
val jvmTest by getting {
dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-junit"))
implementation(libs.ktor.client.okhttp)
}
}
val jsMain by getting {
dependencies {
implementation(kotlin("stdlib-js"))
}
}
val jsTest by getting {
dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-js"))
implementation(libs.ktor.client.js)
}
}
val nativeCommonTest by creating {
dependsOn(commonTest)
}
val desktopCommonTest by creating {
dependsOn(nativeCommonTest)
dependencies {
implementation(libs.ktor.client.curl)
}
}
val win64Test by getting {
dependencies {
implementation(libs.ktor.client.winhttp)
}
}
val macosTest by getting
val linuxX64Test by getting
configure(listOf(macosTest, linuxX64Test)) {
dependsOn(desktopCommonTest)
}
val iosTest by getting {
dependencies {
implementation(libs.coroutines.core)
implementation(libs.ktor.client.darwin)
}
}
// Configure tvos and watchos to build on ios sources
val tvosTest by getting
val watchosArm32Test by getting
val watchosArm64Test by getting
configure(listOf(tvosTest, watchosArm32Test, watchosArm64Test)) {
dependsOn(iosTest)
}
}
}
spotless {
kotlin {
target("**/**.kt")
ktlint(libs.versions.ktlint.get())
.setUseExperimental(true)
.editorConfigOverride(
mapOf(
"ktlint_standard_no-wildcard-imports" to "disabled",
"ktlint_standard_no-unused-imports" to "disabled",
"ij_kotlin_allow_trailing_comma" to "true",
"ij_kotlin_allow_trailing_comma_on_call_site" to "true",
)
)
}
}