-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle.kts
183 lines (160 loc) · 4.99 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
import org.jetbrains.dokka.gradle.engine.parameters.VisibilityModifier
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
val kotlinx_serialization_version: String by extra
val okio_version: String by extra
System.getenv("GIT_REF")?.let { gitRef ->
Regex("refs/tags/v(.*)").matchEntire(gitRef)?.let { gitVersionMatch ->
version = gitVersionMatch.groupValues[1]
}
}
val isSnapshot = version.toString().contains("SNAPSHOT", true)
plugins {
kotlin("multiplatform") version "2.1.0"
kotlin("plugin.serialization") version "2.1.0"
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.16.3"
id("org.jetbrains.dokka") version "2.0.0"
id("maven-publish")
id("signing")
}
repositories {
mavenCentral()
}
kotlin {
explicitApi()
jvm {
compilerOptions {
jvmTarget = JvmTarget.JVM_1_8
}
testRuns["test"].executionTask.configure {
useJUnitPlatform()
}
}
js {
browser {
testTask {
useKarma {
useFirefoxHeadless()
useChromeHeadless()
}
}
}
nodejs()
}
//wasmJs() // Requires gzip/zlib support to be implemented
//wasmWasi()
linuxX64()
linuxArm64()
//androidNativeArm32() // Not supported by Okio yet
//androidNativeArm64() // https://github.com/square/okio/issues/1242#issuecomment-1759357336
//androidNativeX86()
//androidNativeX64()
macosX64()
macosArm64()
iosSimulatorArm64()
iosX64()
watchosSimulatorArm64()
watchosX64()
watchosArm32()
watchosArm64()
tvosSimulatorArm64()
tvosX64()
tvosArm64()
iosArm64()
watchosDeviceArm64()
mingwX64()
sourceSets {
configureEach {
languageSettings.apply {
optIn("kotlin.contracts.ExperimentalContracts")
optIn("net.benwoodworth.knbt.InternalNbtApi")
}
}
val commonMain by getting {
dependencies {
api("org.jetbrains.kotlinx:kotlinx-serialization-core:$kotlinx_serialization_version")
implementation("com.squareup.okio:okio:$okio_version")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinx_serialization_version")
implementation("com.benwoodworth.parameterize:parameterize:0.3.3")
}
}
val jvmTest by getting {
dependencies {
implementation(kotlin("reflect"))
}
}
val jsMain by getting {
dependencies {
implementation(npm("pako", "2.1.0"))
}
}
}
}
dokka {
dokkaSourceSets.all {
documentedVisibilities = setOf(VisibilityModifier.Public)
skipDeprecated = true
}
}
val javadocJar by tasks.registering(Jar::class) {
archiveClassifier = "javadoc"
}
signing {
gradle.taskGraph.whenReady {
isRequired = allTasks.any { it is PublishToMavenRepository }
}
useInMemoryPgpKeys(
System.getenv("SIGNING_KEY_ID"),
System.getenv("SIGNING_KEY"),
System.getenv("SIGNING_PASSWORD"),
)
sign(publishing.publications)
// https://github.com/gradle/gradle/issues/26091#issuecomment-1722947958
tasks.withType<AbstractPublishToMaven>().configureEach {
val signingTasks = tasks.withType<Sign>()
mustRunAfter(signingTasks)
}
}
publishing {
repositories {
maven {
val releasesRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
val snapshotsRepoUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
url = if (isSnapshot) snapshotsRepoUrl else releasesRepoUrl
credentials {
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_TOKEN")
}
}
}
publications.withType<MavenPublication> {
artifact(javadocJar.get())
pom {
name = "knbt"
description = "Minecraft NBT support for kotlinx.serialization"
url = "https://github.com/BenWoodworth/knbt"
licenses {
license {
name = "GNU Lesser General Public License"
url = "https://www.gnu.org/licenses/lgpl-3.0.txt"
}
}
developers {
developer {
id = "BenWoodworth"
name = "Ben Woodworth"
email = "[email protected]"
}
}
scm {
connection = "scm:git:git://github.com:BenWoodworth/knbt.git"
developerConnection = "scm:git:ssh://github.com:BenWoodworth/knbt.git"
url = "https://github.com/BenWoodworth/knbt"
}
}
}
}