-
Notifications
You must be signed in to change notification settings - Fork 41
/
build.gradle.kts
245 lines (223 loc) · 6.58 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
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
import org.gradle.internal.extensions.stdlib.capitalized
import org.jetbrains.kotlin.cli.common.toBooleanLenient
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.testing.internal.KotlinTestReport
val projectName = "konform"
val projectGroup = "io.konform"
val projectDesc = "Konform: Portable validations for Kotlin"
val projectHost = "github"
val projectOrg = "konform-kt"
val projectLicense = "MIT"
val projectLicenseUrl = "https://opensource.org/licenses/MIT"
val projectScmUrl = "https://github.com/konform-kt/konform.git"
val projectInceptionYear = 2018
val kotlinApiTarget = "1.7"
val jvm = JvmTarget.JVM_1_8
/** The "CI" env var is a quasi-standard way to indicate that we're running on CI. */
val onCI: Boolean = System.getenv("CI")?.toBooleanLenient() ?: false
plugins {
alias(libs.plugins.kotest.multiplatform)
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.ktlint)
alias(libs.plugins.nexuspublish)
alias(libs.plugins.kotlinx.binarycompatibilityvalidator)
id("maven-publish")
id("signing")
idea
}
repositories {
mavenCentral()
}
group = projectGroup
val projectVersion = System.getenv("CI_VERSION") ?: "0.11.0-SNAPSHOT"
version = projectVersion
//region Kotlin and test configuration
kotlin {
// Since we are a library, prevent accidentally making things part of the public API
explicitApi()
sourceSets.all {
languageSettings {
languageVersion = kotlinApiTarget
apiVersion = kotlinApiTarget
}
}
//region kotlin targets
androidNativeArm32()
androidNativeArm64()
androidNativeX86()
androidNativeX64()
jvm {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
// note lang toolchain cannot be used here
// because gradle no longer supports running on java 8
jvmTarget = jvm
}
}
js(IR) {
browser {}
nodejs {}
}
iosArm64()
iosSimulatorArm64()
iosX64()
linuxArm64()
linuxX64()
macosArm64()
macosX64()
mingwX64()
tvosArm64()
tvosSimulatorArm64()
tvosX64()
watchosArm32()
watchosArm64()
watchosDeviceArm64()
watchosSimulatorArm64()
watchosX64()
@OptIn(ExperimentalWasmDsl::class)
wasmJs {
browser()
nodejs()
d8()
}
@OptIn(ExperimentalWasmDsl::class)
wasmWasi {
nodejs()
}
//endregion
sourceSets {
// Shared dependencies
commonMain.dependencies {
api(kotlin("stdlib"))
}
// Shared test dependencies
commonTest.dependencies {
implementation(kotlin("test"))
implementation(libs.kotest.assertions.core)
// implementation(kotlin("test-annotations-common"))
// implementation(kotlin("test-common"))
}
jvmTest.dependencies {
implementation(libs.kotlincompiletesting)
// implementation(libs.kotest.runner.junit5)
}
}
}
configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
version = libs.versions.ktlint.get()
}
tasks.named<Test>("jvmTest") {
useJUnitPlatform()
filter {
isFailOnNoMatchingTests = true
}
testLogging {
showExceptions = true
showStandardStreams = true
events =
setOf(
org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED,
org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED,
)
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
}
}
// Disable test tasks for the unsupported source sets
val kotestUnsupported =
listOf(
// https://github.com/kotest/kotest/issues/4015
"wasmWasi",
)
kotestUnsupported.forEach {
// Disable tests for targets kotest doesn't support yet
val capitalized = it.capitalized()
tasks.named("compileTestKotlin$capitalized") {
enabled = false
}
tasks.named<KotlinTestReport>("${it}Test") {
enabled = false
}
}
apiValidation {
apiDumpDirectory = "api"
// ignoredPackages.add("kotlinx.coroutines.internal")
// ignoredClasses.add("com.company.BuildConfig")
}
//endregion
//region Publishing configuration
val javaDocJar =
tasks.register<Jar>("stubJavadoc") {
archiveClassifier = "javadoc"
}
publishing {
publications {
publications.withType(MavenPublication::class) {
artifact(javaDocJar)
pom {
name = projectName
description = projectDesc
url = "https://github.com/konform-kt/konform"
licenses {
license {
name = projectLicense
url = projectLicenseUrl
distribution = "repo"
}
}
developers {
developer {
id = "nlochschmidt"
name = "Niklas Lochschmidt"
}
developer {
id = "dhoepelman"
name = "David Hoepelman"
}
}
scm {
url = projectScmUrl
}
}
}
}
}
signing {
if (onCI) {
val encryptedSigningKey =
layout.projectDirectory
.file(".github/workflows/publishing/github_actions.key.asc")
.asFile
.readText()
useInMemoryPgpKeys(encryptedSigningKey, System.getenv("PGP_PASSPHRASE"))
} else {
useGpgCmd()
}
sign(publishing.publications)
}
// Fix Gradle warning about signing tasks using publishing task outputs without explicit dependencies
// https://github.com/gradle/gradle/issues/26091
tasks.withType<AbstractPublishToMaven>().configureEach {
val signingTasks = tasks.withType<Sign>()
mustRunAfter(signingTasks)
}
nexusPublishing {
repositories {
sonatype {
// Fallback to empty for local and CI builds with no access to the secrets
// They should not need to publish anyway
username = System.getenv("MAVEN_CENTRAL_TOKEN_USER") ?: ""
password = System.getenv("MAVEN_CENTRAL_TOKEN_PW") ?: ""
}
}
}
//endregion
//region IDE configuration
idea {
module {
isDownloadJavadoc = true
isDownloadSources = true
}
}
//endregion