-
Notifications
You must be signed in to change notification settings - Fork 39
/
build.gradle.kts
181 lines (168 loc) · 4.82 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
import org.jetbrains.kotlin.cli.common.toBooleanLenient
import org.jetbrains.kotlin.config.JvmTarget
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 jvmTarget = JvmTarget.JVM_1_8
val javaVersion = 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 {
kotlin("multiplatform") version "1.9.24"
id("maven-publish")
id("signing")
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
id("org.jlleitschuh.gradle.ktlint") version "12.1.1"
idea
}
repositories {
mavenCentral()
}
group = projectGroup
val projectVersion = System.getenv("CI_VERSION") ?: "0.6.0-SNAPSHOT"
version = projectVersion
kotlin {
// Since we are a library, prevent accidentally making things part of the public API
explicitApi()
sourceSets.all {
languageSettings {
languageVersion = kotlinApiTarget
apiVersion = kotlinApiTarget
}
}
jvm {
compilations.all {
kotlinOptions.jvmTarget = jvmTarget.toString()
}
withJava()
testRuns["test"].executionTask.configure {
useJUnitPlatform()
}
}
jvmToolchain {
languageVersion = JavaLanguageVersion.of(javaVersion)
}
js(IR) {
browser {}
nodejs {}
}
// linuxX64()
// linuxArm64()
// linuxArm32Hfp()
// linuxMips32()
// linuxMipsel32()
// ios()
// iosX64()
// iosArm64()
// iosSimulatorArm64()
// macosX64()
// macosArm64()
// tvos()
// tvosArm64()
// tvosSimulatorArm64()
// tvosX64()
// watchos()
// watchosArm32()
// watchosSimulatorArm64()
// watchosArm64()
// watchosX86()
// watchosX64()
// wasm()
// wasm32()
// mingwX86()
// mingwX64()
sourceSets {
val commonMain by getting {
dependencies {
compileOnly(kotlin("stdlib"))
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val jvmMain by getting {
dependencies {
compileOnly(kotlin("stdlib-jdk8"))
}
}
}
}
configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
version = "1.2.1"
}
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)
}
//region 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") ?: ""
}
}
}
idea {
module {
isDownloadJavadoc = true
isDownloadSources = true
}
}