-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
166 lines (143 loc) · 4.47 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
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
plugins {
kotlin("multiplatform") version "2.0.0"
kotlin("plugin.serialization") version "2.0.0"
id("org.jetbrains.dokka") version "1.9.20"
id("maven-publish")
id("signing")
}
fun findProperty(name: String): String? = if (hasProperty(name)) property(name) as String else System.getenv(name)
fun findFilledProperty(name: String): String? = findProperty(name)?.ifBlank { null }
group = findProperty("group")!!
version = findProperty("version")!!
val ossrhUsername = findFilledProperty("ossrh.username")
val ossrhPassword = findFilledProperty("ossrh.password")
val ossrhMavenEnabled = ossrhUsername != null && ossrhPassword != null
val isSigningEnabled = findFilledProperty("signing.keyId") != null &&
findFilledProperty("signing.password") != null &&
findFilledProperty("signing.secretKeyRingFile") != null
repositories {
mavenCentral()
}
kotlin {
jvm {
withJava()
withSourcesJar(true)
testRuns.named("test") {
executionTask.configure { useJUnitPlatform() }
}
}
// web
js(IR) {
browser()
nodejs()
}
@OptIn(ExperimentalWasmDsl::class)
wasmJs { d8() }
@OptIn(ExperimentalWasmDsl::class)
wasmWasi { nodejs() }
// https://kotlinlang.org/docs/native-target-support.html
// Tier1
macosX64()
macosArm64()
iosSimulatorArm64()
iosX64()
// Tier2
linuxX64()
linuxArm64()
watchosSimulatorArm64()
watchosX64()
watchosArm32()
watchosArm64()
tvosSimulatorArm64()
tvosX64()
tvosArm64()
iosArm64()
// Tier3
androidNativeArm32()
androidNativeArm64()
androidNativeX86()
androidNativeX64()
mingwX64()
watchosDeviceArm64()
sourceSets {
getByName("commonMain") {
dependencies {
val serialization = findProperty("version.serialization")!!
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$serialization")
}
}
getByName("commonTest") {
dependencies {
implementation(kotlin("test"))
}
}
}
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask::class.java) {
compilerOptions {
apiVersion.set(KotlinVersion.KOTLIN_2_0)
languageVersion.set(KotlinVersion.KOTLIN_2_0)
}
}
publishing {
publications.withType<MavenPublication> {
val publicationName = [email protected]
val javadocJar = tasks.register("${publicationName}JavadocJar", Jar::class) {
archiveClassifier.set("javadoc")
archiveBaseName.set("${archiveBaseName.get()}-${publicationName}")
}
artifact(javadocJar)
pom {
name.set(findProperty("POM_NAME")!!)
description.set(findProperty("POM_DESCRIPTION")!!)
url.set(findProperty("POM_URL")!!)
licenses {
license {
name.set(findProperty("POM_LICENSE_NAME")!!)
url.set(findProperty("POM_LICENSE_URL")!!)
}
}
developers {
developer {
id.set(findProperty("POM_DEVELOPER_LBRIAND_ID")!!)
name.set(findProperty("POM_DEVELOPER_LBRIAND_NAME")!!)
email.set(findProperty("POM_DEVELOPER_LBRIAND_EMAIL")!!)
}
}
scm {
connection.set(findProperty("POM_SCM_URL")!!)
developerConnection.set(findProperty("POM_SCM_CONNECTION")!!)
url.set(findProperty("POM_SCM_DEV_CONNECTION")!!)
}
}
}
repositories {
mavenLocal()
if (ossrhMavenEnabled) {
maven {
name = "sonatype"
setUrl("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = ossrhUsername
password = ossrhPassword
}
}
}
}
}
if (isSigningEnabled) {
signing {
sign(publishing.publications)
}
}
tasks.create<Delete>("cleanupGithubDocumentation") {
delete(file("docs"))
}
tasks.create<Copy>("generateGithubDocumentation") {
dependsOn("cleanupGithubDocumentation")
dependsOn("dokkaHtml")
val buildDir = layout.buildDirectory
from(buildDir.dir("dokka/html")).into("docs")
}