This repository has been archived by the owner on Jun 22, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
201 lines (174 loc) · 5.1 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
199
200
201
import org.gradle.configurationcache.extensions.capitalized
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
plugins {
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.kotlin.plugin.serialization)
alias(libs.plugins.kotlinx.kover)
alias(libs.plugins.dokka)
alias(libs.plugins.kotlinter)
`maven-publish`
signing
}
allprojects {
apply(plugin = "org.jmailen.kotlinter")
group = "dev.s7a"
version = "1.1.0"
repositories {
mavenCentral()
}
}
kotlin {
explicitApi()
jvm()
js {
browser()
nodejs()
}
// Android
// androidNativeX86()
// androidNativeX64()
// androidNativeArm32()
// androidNativeArm64()
// Linux
linuxArm64()
linuxX64()
// Windows
mingwX64()
// MacOS
macosArm64()
macosX64()
iosArm64()
iosSimulatorArm64()
iosX64()
tvosArm64()
tvosSimulatorArm64()
tvosX64()
watchosArm32()
watchosArm64()
watchosSimulatorArm64()
// watchosDeviceArm64()
watchosX64()
sourceSets {
commonMain {
dependencies {
implementation(libs.kotlinx.coroutines.core)
implementation(libs.ktor.client.core)
implementation(libs.ktor.client.content.negotiation)
implementation(libs.ktor.serialization.kotlinx.json)
}
}
commonTest {
dependencies {
implementation(libs.kotlin.test)
implementation(libs.ktor.client.mock)
implementation(libs.kotlinx.coroutines.test)
}
}
}
}
tasks.withType(KotlinJvmCompile::class.java).configureEach {
kotlinOptions.apply {
jvmTarget = "1.8"
}
}
tasks.withType<DokkaTask>().configureEach {
val dokkaDir = projectDir.resolve("dokka")
val version = version.toString()
dependencies {
dokkaPlugin(libs.dokka.plugin.versioning)
}
outputDirectory.set(file(dokkaDir.resolve(version)))
pluginsMapConfiguration.set(
mapOf(
"org.jetbrains.dokka.versioning.VersioningPlugin" to """
{
"version": "$version",
"olderVersionsDir": "$dokkaDir"
}
""".trimIndent(),
),
)
}
tasks.named("dokkaHtml") {
val dokkaDir = projectDir.resolve("dokka")
doFirst {
dokkaDir.listFiles()?.forEach { file ->
if (file != null && file.isDirectory && file.name.endsWith("-SNAPSHOT")) {
file.deleteRecursively()
}
}
}
doLast {
if (version.toString().endsWith("-SNAPSHOT").not()) {
dokkaDir.resolve("index.html").writeText(
"""
<!DOCTYPE html>
<meta charset="utf-8">
<meta http-equiv="refresh" content="0; URL=./$version/">
<link rel="canonical" href="./$version/">
""".trimIndent(),
)
}
}
}
val javadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
}
publishing {
repositories {
maven {
url = uri(
if (version.toString().endsWith("SNAPSHOT")) {
"https://s01.oss.sonatype.org/content/repositories/snapshots/"
} else {
"https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
},
)
credentials {
username = properties["sonatypeUsername"].toString()
password = properties["sonatypePassword"].toString()
}
}
}
publications.withType<MavenPublication> {
artifact(javadocJar.get())
pom {
name.set("Gofile.kt")
description.set("A kotlin wrapper for the Gofile.io API")
url.set("https://github.com/sya-ri/Gofile.kt")
licenses {
license {
name.set("Apache License 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0")
}
}
developers {
developer {
id.set("sya-ri")
name.set("sya-ri")
email.set("[email protected]")
}
}
scm {
url.set("https://github.com/sya-ri/Gofile.kt")
}
}
}
}
afterEvaluate {
val targetNames = kotlin.targets.names.map(String::capitalized) + "KotlinMultiplatform"
val publishTasks = targetNames.mapNotNull { tasks.findByName("publish${it}PublicationToMavenRepository") }
val signTasks = targetNames.mapNotNull { tasks.findByName("sign${it}Publication") }
publishTasks.forEach { publishTask ->
signTasks.forEach { signTask ->
publishTask.dependsOn(signTask)
}
}
}
signing {
val key = properties["signingKey"]?.toString()?.replace("\\n", "\n")
val password = properties["signingPassword"]?.toString()
useInMemoryPgpKeys(key, password)
sign(publishing.publications)
}