-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
143 lines (124 loc) · 3.74 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
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
plugins {
kotlin("multiplatform") version "1.9.22"
kotlin("plugin.serialization") version "1.9.22"
id("org.jetbrains.dokka") version "1.9.10"
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("osshr.username")
val ossrhPassword = findFilledProperty("osshr.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 {
compilations.getByName("main") {
kotlinOptions { jvmTarget = "1.8" }
}
jvmToolchain(8)
withJava()
withSourcesJar(true)
testRuns.named("test") {
executionTask.configure { useJUnitPlatform() }
}
}
// web
js {
browser()
nodejs()
}
@OptIn(ExperimentalWasmDsl::class)
wasmJs { d8() }
// 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("commonTest") {
dependencies {
implementation(kotlin("test"))
}
}
}
}
publishing {
publications.withType<MavenPublication> {
val publicationName = this@withType.name
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)
}
}