-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle.kts
178 lines (153 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
import com.goncalossilva.useanybrowser.useAnyBrowser
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockMismatchReport
plugins {
kotlin("multiplatform") version "2.1.0"
id("com.goncalossilva.resources") version "0.10.0"
id("com.goncalossilva.useanybrowser") version "0.3.0"
id("maven-publish")
id("signing")
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
id("io.gitlab.arturbosch.detekt") version "1.23.7"
}
repositories {
mavenCentral()
gradlePluginPortal()
}
kotlin {
explicitApi()
jvm {
compilerOptions {
jvmTarget = JvmTarget.JVM_1_8
}
}
js(IR) {
browser {
testTask {
useKarma {
useAnyBrowser()
}
}
}
nodejs {
testTask {
useMocha {
// Disable test case timeout, bringing parity with other platforms.
timeout = "0"
}
}
}
}
iosArm64()
iosX64()
iosSimulatorArm64()
watchosArm32()
watchosArm64()
watchosSimulatorArm64()
tvosArm64()
tvosX64()
tvosSimulatorArm64()
mingwX64()
macosX64()
macosArm64()
linuxX64()
linuxArm64()
applyDefaultHierarchyTemplate()
sourceSets {
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
implementation("com.goncalossilva:resources:0.10.0")
}
}
}
}
rootProject.configure<NodeJsRootExtension> {
version = "22.12.0"
}
rootProject.plugins.withType<YarnPlugin> {
rootProject.configure<YarnRootExtension> {
version = "1.22.22"
yarnLockMismatchReport = YarnLockMismatchReport.WARNING
yarnLockAutoReplace = true
}
}
// TODO: Remove when https://youtrack.jetbrains.com/issue/KT-46466 is fixed.
val signingTasks = tasks.withType<Sign>()
tasks.withType<AbstractPublishToMaven>().configureEach {
dependsOn(signingTasks)
}
val javadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
}
// Setup publishing.
publishing {
// Configure all publications.
publications.withType<MavenPublication> {
// Publish docs with each artifact.
artifact(javadocJar)
// Provide information requited by Maven Central.
pom {
name.set(rootProject.name)
description.set(findProperty("pomDescription") as String)
url.set(findProperty("pomUrl") as String)
licenses {
license {
name.set(findProperty("pomLicenseName") as String)
url.set(findProperty("pomLicenseUrl") as String)
}
}
scm {
url.set(findProperty("pomScmUrl") as String)
connection.set(findProperty("pomScmConnection") as String)
developerConnection.set(findProperty("pomScmDeveloperConnection") as String)
}
developers {
developer {
id.set(findProperty("pomDeveloperId") as String)
name.set(findProperty("pomDeveloperName") as String)
}
}
}
}
}
// Sign artifacts.
signing {
// Use `signingKey` and `signingPassword` properties if provided.
// Otherwise, default to `signing.keyId`, `signing.password` and `signing.secretKeyRingFile`.
val signingKey: String? by project
val signingPassword: String? by project
if (signingKey != null && signingPassword != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
}
sign(publishing.publications)
}
// Leverage Gradle Nexus Publish Plugin to create, close and release staging repositories,
// covering the last part of the release process to Maven Central.
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
// Read `ossrhUsername` and `ossrhPassword` properties.
// DO NOT ADD THESE TO SOURCE CONTROL. Store them in your system properties,
// or pass them in using ORG_GRADLE_PROJECT_* environment variables.
val ossrhUsername: String? by project
val ossrhPassword: String? by project
val ossrhStagingProfileId: String? by project
username.set(ossrhUsername)
password.set(ossrhPassword)
stagingProfileId.set(ossrhStagingProfileId)
}
}
}
// Install git hooks automatically.
gradle.taskGraph.whenReady {
val from = File("${rootProject.rootDir}/config/detekt/pre-commit")
val to = File("${rootProject.rootDir}/.git/hooks/pre-commit")
from.copyTo(to, overwrite = true)
to.setExecutable(true)
}