-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
211 lines (187 loc) · 6.25 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
kotlin("multiplatform")
id("org.jetbrains.dokka")
`maven-publish`
signing
id("io.github.gradle-nexus.publish-plugin")
}
val sharedGroup = "com.kgit2"
val sharedVersion = "2.2.1"
group = sharedGroup
version = sharedVersion
repositories {
mavenCentral()
gradlePluginPortal()
}
subprojects {
group = sharedGroup
version = sharedVersion
}
kotlin {
jvm {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
withJava()
testRuns["test"].executionTask.configure {
useJUnitPlatform()
}
}
val nativeTargets = listOf(
macosX64() to Platform.MACOS_X64,
macosArm64() to Platform.MACOS_ARM64,
linuxX64() to Platform.LINUX_X64,
linuxArm64() to Platform.LINUX_ARM64,
mingwX64() to Platform.MINGW_X64,
)
nativeTargets.forEach { (nativeTarget, targetPlatform) ->
nativeTarget.apply {
compilations.getByName("main") {
cinterops {
create("kommandCore") {
defFile(project.file("src/nativeInterop/cinterop/${targetPlatform.archName}.def"))
packageName("kommand_core")
}
}
}
}
}
applyDefaultHierarchyTemplate()
sourceSets {
// add opt-in
all {
// languageSettings.optIn("kotlinx.cinterop.UnsafeNumber")
languageSettings.optIn("kotlinx.cinterop.ExperimentalForeignApi")
languageSettings.optIn("kotlin.experimental.ExperimentalNativeApi")
// languageSettings.optIn("kotlin.native.runtime.NativeRuntimeApi")
languageSettings.optIn("kotlin.ExperimentalStdlibApi")
languageSettings {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
freeCompilerArgs.add("-Xexpect-actual-classes")
}
}
}
commonMain {
dependencies {
implementation("org.jetbrains.kotlinx:atomicfu:0.23.1")
}
}
commonTest {
dependencies {
implementation(kotlin("test"))
}
}
}
}
val testString: String by project
tasks {
withType(Wrapper::class) {
distributionType = Wrapper.DistributionType.ALL
gradleVersion = "8.2"
}
withType(Test::class) {
testLogging {
showStandardStreams = true
}
}
}
val ossrhUrl: String = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
val releasesRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
val snapshotsRepoUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
val ossrhUsername = runCatching {
val ossrhUsername: String by project
ossrhUsername
}.getOrNull()
val ossrhPassword = runCatching {
val ossrhPassword: String by project
ossrhPassword
}.getOrNull()
if (ossrhUsername != null && ossrhPassword != null) {
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username.set(ossrhUsername)
password.set(ossrhPassword)
}
}
}
publishing {
repositories {
mavenLocal()
maven {
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
credentials {
username = ossrhUsername
password = ossrhPassword
}
}
}
publications {
withType<MavenPublication> {
val dokkaJar = project.tasks.register("${name}DokkaJar", Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Assembles Kotlin docs with Dokka into a Javadoc jar"
archiveClassifier.set("javadoc")
from(tasks.dokkaHtml)
// Each archive name should be distinct, to avoid implicit dependency issues.
// We use the same format as the sources Jar tasks.
// https://youtrack.jetbrains.com/issue/KT-46466
archiveBaseName.set("${archiveBaseName.get()}-${name}")
}
artifact(dokkaJar)
pom {
name.set("kommand")
description.set("A simple process library for Kotlin Multiplatform")
url.set("https://github.com/kgit2/kommand")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
scm {
connection.set("https://github.com/kgit2/kommand.git")
url.set("https://github.com/kgit2/kommand")
}
developers {
developer {
id.set("BppleMan")
name.set("BppleMan")
email.set("bppleman@gmail.com")
}
}
}
}
}
}
signing {
// will default find the
// - signing.keyId
// - signing.password
// - signing.secretKeyRingFile
sign(publishing.publications)
}
}
enum class Platform(
val archName: String
) {
MACOS_X64("x86_64-apple-darwin"),
MACOS_ARM64("aarch64-apple-darwin"),
LINUX_X64("x86_64-unknown-linux-gnu"),
LINUX_ARM64("aarch64-unknown-linux-gnu"),
MINGW_X64("x86_64-pc-windows-gnu"),
;
}
val platforms: List<Platform> = listOf(
Platform.MACOS_X64,
Platform.MACOS_ARM64,
Platform.LINUX_X64,
Platform.LINUX_ARM64,
Platform.MINGW_X64,
)