-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
228 lines (215 loc) · 7.63 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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
import org.jetbrains.dokka.gradle.DokkaTaskPartial
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.net.URL
import java.util.Base64
group = "no.dossier.libraries"
version = "0.2.8"
object Meta {
const val desc = "RabbitMQ Kotlin Client library"
const val license = "MIT"
const val githubRepo = "dossiersolutions/amqp-connector"
const val releaseRepoUrl = "https://s01.oss.sonatype.org/service/local/"
const val snapshotRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
}
fun MavenPom.commonMetadata() {
name.set(project.name)
description.set(Meta.desc)
url.set("https://github.com/${Meta.githubRepo}")
licenses {
license {
name.set(Meta.license)
url.set("https://opensource.org/licenses/MIT")
}
}
developers {
developer {
id.set("kubapet")
name.set("Jakub Petrzilka")
organization.set("Dossier Solutions")
organizationUrl.set("https://dossier.no/")
}
}
scm {
url.set(
"https://github.com/${Meta.githubRepo}.git"
)
connection.set(
"scm:git:git://github.com/${Meta.githubRepo}.git"
)
developerConnection.set(
"scm:git:git://github.com/${Meta.githubRepo}.git"
)
}
issueManagement {
url.set("https://github.com/${Meta.githubRepo}/issues")
}
}
repositories {
mavenCentral()
}
plugins {
id("org.gradle.maven-publish")
id("org.gradle.signing")
kotlin("multiplatform") version "1.9.20"
id("org.jetbrains.dokka") version "1.9.10"
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
kotlin("plugin.serialization") version "1.9.20"
}
kotlin {
jvm()
/*linuxX64("native") {
binaries {
sharedLib {
baseName = "native"
}
}
}*/
sourceSets {
val commonMain by existing {
dependencies {
implementation("no.dossier.libraries:functional:0.2.4")
implementation("no.dossier.libraries:error-handling:0.1.2")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
implementation("io.github.microutils:kotlin-logging:2.0.11")
implementation("org.jetbrains.kotlin:kotlin-stdlib")
}
}
/*val nativeMain by existing {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-linuxx64:1.6.4")
}
}*/
val jvmMain by existing {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.7.3")
implementation("com.rabbitmq:amqp-client:5.20.0")
implementation("io.github.microutils:kotlin-logging-jvm:2.0.11")
}
}
val jvmTest by existing {
dependencies {
implementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
implementation("org.junit.jupiter:junit-jupiter-params:5.8.1")
runtimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
runtimeOnly("ch.qos.logback:logback-classic:1.2.11")
implementation("org.testcontainers:rabbitmq:1.16.2")
implementation("org.testcontainers:junit-jupiter:1.16.2")
}
}
val jvmDoc by creating {
kotlin.srcDir("src/jvmDoc/kotlin")
dependsOn(jvmMain.get())
}
}
}
tasks {
withType<Test> {
useJUnitPlatform()
}
withType<KotlinCompile> { kotlinOptions.jvmTarget = "21" }
withType<DokkaTaskPartial>().configureEach {
dokkaSourceSets {
removeIf { it.name == "jvmDoc" }
named("jvmMain") {
includes.from("${projectDir}/src/jvmDoc/packages.md")
includes.from("${projectDir}/src/jvmDoc/module.md")
suppressObviousFunctions.set(true)
suppressInheritedMembers.set(true)
samples.from("${projectDir}/src/jvmDoc/kotlin")
if (file("${projectDir}/src/jvmMain").exists()) {
sourceLink {
localDirectory.set(file("src/jvmMain/kotlin"))
remoteUrl.set(
URL(
"https://github.com/dossiersolutions/${projectDir.name}/src/jvmMain/kotlin"
)
)
remoteLineSuffix.set("#lines-")
}
}
}
}
}
val dokkaHtml by existing
val javadocKotlinMultiplatformJar by registering(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Assembles Javadoc JAR for KotlinMultiplatform publication"
archiveClassifier.set("javadoc")
archiveAppendix.set("")
from(dokkaHtml.get())
}
/*val javadocNativeJar by registering(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Assembles Javadoc JAR for Native publication"
archiveClassifier.set("javadoc")
archiveAppendix.set("native")
from(dokkaHtml.get())
}*/
val javadocJvmJar by registering(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Assembles Javadoc JAR for JVM publication"
archiveClassifier.set("javadoc")
archiveAppendix.set("jvm")
from(dokkaHtml.get())
}
val publish by existing {
dependsOn(javadocKotlinMultiplatformJar, javadocJvmJar/*, javadocNativeJar*/)
}
}
signing {
val signingKey = System.getenv("GPG_SIGNING_KEY")?.let { String(Base64.getDecoder().decode(it)) }
val signingPassphrase = System.getenv("GPG_SIGNING_PASSPHRASE")
useInMemoryPgpKeys(signingKey, signingPassphrase)
val extension = extensions.getByName("publishing") as PublishingExtension
sign(extension.publications)
}
publishing {
repositories {
maven {
name = "DossierNexus"
url = uri("https://devsrv.dossier.no/nexus/repository/maven-releases/")
credentials {
// Read nexus username and password from env (CI) or ~/.gradle/gradle.properties
username = System.getenv("MAVEN_REPO_USERNAME") ?: project.property("nexusUsername")!!.toString()
password = System.getenv("MAVEN_REPO_PASSWORD") ?: project.property("nexusPassword")!!.toString()
}
metadataSources {
mavenPom()
artifact()
}
}
}
publications {
/*val native by existing(MavenPublication::class) {
artifact(tasks["javadocNativeJar"])
pom {
commonMetadata()
}
}*/
val jvm by existing(MavenPublication::class) {
artifact(tasks["javadocJvmJar"])
pom {
commonMetadata()
}
}
val kotlinMultiplatform by existing(MavenPublication::class) {
artifact(tasks["javadocKotlinMultiplatformJar"])
pom {
commonMetadata()
}
}
}
}
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri(Meta.releaseRepoUrl))
snapshotRepositoryUrl.set(uri(Meta.snapshotRepoUrl))
val ossrhUsername = System.getenv("OSSRH_USERNAME")
val ossrhPassword = System.getenv("OSSRH_PASSWORD")
username.set(ossrhUsername)
password.set(ossrhPassword)
}
}
}