Repository navigation
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
259 lines (232 loc) · 6.54 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
259 lines (232 loc) · 6.54 KB
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
@file:OptIn(ExperimentalWasmDsl::class)
import fr.brouillard.oss.jgitver.Strategies
import love.forte.plugin.suspendtrans.configuration.SuspendTransformConfigurations.kotlinJsExportIgnoreClassInfo
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import ru.vyarus.gradle.plugin.mkdocs.task.MkdocsTask
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.composeCompiler) apply false
alias(libs.plugins.compose) apply false
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.mavenPublish)
alias(libs.plugins.spotless)
alias(libs.plugins.dokka)
alias(libs.plugins.mkdocs)
alias(libs.plugins.jgitver)
alias(libs.plugins.suspendTransformCompiler)
alias(libs.plugins.kover)
alias(libs.plugins.npmPublish)
id("maven-publish")
}
group = "co.pokeapi.pokekotlin"
jgitver {
strategy(Strategies.MAVEN)
nonQualifierBranches("main")
}
kotlin {
jvmToolchain(21)
explicitApiWarning()
compilerOptions {
optIn = listOf("kotlin.js.ExperimentalJsExport")
allWarningsAsErrors = true
freeCompilerArgs.addAll(
"-Xexpect-actual-classes",
"-Xcontext-sensitive-resolution",
"-Xconsistent-data-class-copy-visibility",
)
}
jvm()
js(IR) {
browser { testTask { useMocha { timeout = "10min" } } }
nodejs { testTask { useMocha { timeout = "10min" } } }
useEsModules()
binaries.library()
generateTypeScriptDefinitions()
}
wasmJs {
browser()
nodejs()
d8()
}
// native tier 1
macosX64()
macosArm64()
iosSimulatorArm64()
iosX64()
iosArm64()
// native tier 2
linuxX64()
linuxArm64()
watchosSimulatorArm64()
watchosX64()
watchosArm32()
watchosArm64()
tvosSimulatorArm64()
tvosX64()
tvosArm64()
// native tier 3
// android native platforms aren't supported due to lack of Ktor support
mingwX64()
watchosDeviceArm64()
applyDefaultHierarchyTemplate()
sourceSets {
commonMain.dependencies {
implementation(kotlin("stdlib"))
implementation(libs.kotlinx.serialization.json)
implementation(libs.ktor.client.content.negotiation)
implementation(libs.ktor.serialization.kotlinx.json)
}
val nonJsMain by creating { dependsOn(commonMain.get()) }
jvmMain {
dependsOn(nonJsMain)
dependencies { implementation(libs.ktor.client.okhttp) }
}
appleMain {
dependsOn(nonJsMain)
dependencies { implementation(libs.ktor.client.darwin) }
}
linuxMain {
dependsOn(nonJsMain)
dependencies { implementation(libs.ktor.client.curl) }
}
mingwMain {
dependsOn(nonJsMain)
dependencies { implementation(libs.ktor.client.winhttp) }
}
jsMain { dependencies { implementation(libs.ktor.client.js) } }
wasmJsMain {
dependsOn(nonJsMain)
dependencies { implementation(libs.ktor.client.js) }
}
commonTest.dependencies {
implementation(kotlin("test"))
implementation(libs.kotlinx.coroutines.test)
implementation(libs.kotlinx.io)
implementation(libs.ktor.client.mock)
}
jvmTest.dependencies { implementation(kotlin("reflect")) }
}
}
tasks
.matching { task ->
listOf(
// disable ios/watchos/tvos tests
".*Simulator.*Test",
// disable D8 tests
".*D8Test",
)
.any { task.name.matches(it.toRegex()) }
}
.configureEach { enabled = false }
suspendTransformPlugin {
transformers {
addJvmAsync()
addJvmBlocking()
addJsPromise { addCopyAnnotationExclude { from(kotlinJsExportIgnoreClassInfo) } }
}
}
npmPublish {
readme = project.file("README.npm.md")
packages {
named("js") {
scope = "pokeapi"
packageJson {
description = "Promise based client for PokéAPI written in Kotlin"
keywords = setOf("pokeapi", "pokemon", "api", "kotlin")
homepage = "https://pokeapi.github.io/pokekotlin/"
license = "Apache-2.0"
author {
name = "Sargun Vohra"
url = "https://github.com/sargunv"
}
bugs { url = "https://github.com/PokeAPI/pokekotlin/issues" }
repository {
type = "git"
url = "git+https://github.com/PokeAPI/pokekotlin.git"
}
}
}
}
registries {
npmjs { authToken = project.properties["npmAccessToken"]?.toString() }
github { authToken = project.properties["GitHubPackagesPassword"]?.toString() }
}
}
publishing {
repositories {
maven {
name = "GitHubPackages"
setUrl("https://maven.pkg.github.com/PokeAPI/pokekotlin")
credentials(PasswordCredentials::class)
}
}
}
mavenPublishing {
publishToMavenCentral(automaticRelease = true)
signAllPublications()
pom {
name = "PokeKotlin"
description = "Kotlin client for PokéAPI"
url = "https://pokeapi.github.io/pokekotlin/"
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://opensource.org/license/apache-2-0")
distribution.set("repo")
}
}
developers {
developer {
id.set("sargunv")
name.set("Sargun Vohra")
url.set("https://github.com/sargunv")
}
}
scm {
url.set("https://github.com/PokeAPI/pokekotlin")
connection.set("scm:git:git://github.com/PokeAPI/pokekotlin.git")
developerConnection.set("scm:git:ssh://git@github.com/PokeAPI/pokekotlin.git")
}
}
}
dokka {
moduleName = "PokeKotlin API Reference"
dokkaSourceSets {
configureEach {
includes.from("MODULE.md")
sourceLink {
remoteUrl("https://github.com/PokeAPI/pokekotlin/tree/${project.ext["base_tag"]}/")
localDirectory.set(rootDir)
}
externalDocumentationLinks { create("ktor") { url("https://api.ktor.io/") } }
suppressedFiles.from("build/generated/ksp/")
}
}
}
mkdocs {
sourcesDir = "docs"
strict = true
publish {
docPath = null // single version site
}
}
tasks.withType<MkdocsTask>().configureEach {
val releaseVersion = ext["base_tag"].toString().replace("v", "")
val snapshotVersion = "${ext["next_patch_version"]}-SNAPSHOT"
extras.set(mapOf("release_version" to releaseVersion, "snapshot_version" to snapshotVersion))
}
tasks.register("generateDocs") {
dependsOn("dokkaGenerate", "mkdocsBuild")
doLast {
copy {
from(layout.buildDirectory.dir("mkdocs"))
into(layout.buildDirectory.dir("docs"))
}
copy {
from(layout.buildDirectory.dir("dokka/html"))
into(layout.buildDirectory.dir("docs/api"))
}
}
}
tasks.named("clean") { doLast { delete("${rootProject.projectDir}/.git/hooks/pre-commit") } }