Skip to content

Commit edc02d7

Browse files
committed
Switch to maven central publishing
1 parent ade03a0 commit edc02d7

File tree

2 files changed

+51
-77
lines changed

2 files changed

+51
-77
lines changed

.github/workflows/cd.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@ jobs:
2525
run: ./gradlew check
2626

2727
- name: Publish
28-
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
28+
run: ./gradlew publishToMavenCentral
2929
env:
30-
OSSRHUSER: ${{ secrets.OSSRHUSER }}
31-
OSSRHPASSWORD: ${{ secrets.OSSRHPASSWORD }}
3230
GITHUB_VERSION: ${{ github.event.release.tag_name }}
33-
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
34-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
31+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
32+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
33+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_PRIVATE_KEY }}
34+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.GPG_KEY_ID }}
35+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_KEY_PASSWORD }}
3536

3637
- name: Upload Gradle reports
3738
uses: actions/upload-artifact@v4

build.gradle.kts

Lines changed: 45 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
2+
import com.vanniktech.maven.publish.JavadocJar
3+
import com.vanniktech.maven.publish.KotlinJvm
4+
import com.vanniktech.maven.publish.SonatypeHost
25
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
36

47
plugins {
5-
id("signing")
6-
id("maven-publish")
78
kotlin("jvm") version "1.9.23"
89
id("org.jetbrains.kotlin.plugin.spring") version "1.9.23"
910
id("dev.adamko.dokkatoo-html") version "2.2.0"
1011
id("dev.adamko.dokkatoo-javadoc") version "2.2.0"
1112
id("io.gitlab.arturbosch.detekt") version "1.23.5"
1213
id("org.jmailen.kotlinter") version "4.3.0"
1314
id("com.adarshr.test-logger") version "4.0.0"
14-
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
15+
id("com.vanniktech.maven.publish") version "0.29.0"
1516
id("com.github.ben-manes.versions") version "0.51.0"
1617
}
1718

@@ -54,9 +55,6 @@ dependencies {
5455
java {
5556
sourceCompatibility = JavaVersion.VERSION_17
5657
targetCompatibility = JavaVersion.VERSION_17
57-
58-
withJavadocJar()
59-
withSourcesJar()
6058
}
6159

6260
kotlin {
@@ -73,10 +71,6 @@ detekt {
7371
buildUponDefaultConfig = true
7472
}
7573

76-
tasks.named<Jar>("javadocJar") {
77-
from(tasks.named("dokkatooGeneratePublicationJavadoc"))
78-
}
79-
8074
dokkatoo {
8175
val jacksonVersion = resolveVersion("com.fasterxml.jackson.core:jackson-core")
8276
val mqttClientVersion = resolveVersion("com.hivemq:hivemq-mqtt-client")
@@ -118,71 +112,50 @@ fun isNonStable(version: String): Boolean {
118112
return !isStable
119113
}
120114

121-
publishing {
122-
publications {
123-
create<MavenPublication>("maven") {
124-
artifactId = "mqtt-starter"
125-
126-
from(components["java"])
127-
128-
pom {
129-
name = "Mqtt-Starter"
130-
description = "Spring Boot Starter wrapping the hivemq mqtt client."
131-
url = "https://github.com/SmartsquareGmbH/mqtt-starter"
132-
133-
licenses {
134-
license {
135-
name = "MIT License"
136-
url = "https://opensource.org/licenses/MIT"
137-
}
138-
}
139-
developers {
140-
developer {
141-
id = "deen13"
142-
name = "Dennis Dierkes"
143-
144-
}
145-
developer {
146-
id = "rubengees"
147-
name = "Ruben Gees"
148-
149-
}
150-
}
151-
scm {
152-
connection = "scm:git:https://github.com/SmartsquareGmbH/mqtt-starter.git"
153-
developerConnection = "scm:git:ssh://github.com/SmartsquareGmbH/mqtt-starter.git"
154-
url = "https://github.com/SmartsquareGmbH/mqtt-starter"
155-
}
156-
organization {
157-
name = "Smartsquare GmbH"
158-
url = "https://github.com/SmartsquareGmbH"
159-
}
160-
issueManagement {
161-
system = "GitHub"
162-
url = "https://github.com/SmartsquareGmbH/mqtt-starter/issues"
163-
}
115+
mavenPublishing {
116+
configure(KotlinJvm(JavadocJar.Dokka("dokkatooGeneratePublicationJavadoc")))
117+
118+
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, automaticRelease = true)
119+
signAllPublications()
120+
121+
pom {
122+
name = "Mqtt-Starter"
123+
description = "Spring Boot Starter wrapping the hivemq mqtt client."
124+
url = "https://github.com/SmartsquareGmbH/mqtt-starter"
125+
inceptionYear = "2021"
126+
127+
licenses {
128+
license {
129+
name = "MIT License"
130+
url = "https://opensource.org/license/mit"
131+
distribution = "https://opensource.org/license/mit"
164132
}
165133
}
166-
}
167-
}
168-
169-
nexusPublishing {
170-
repositories {
171-
sonatype {
172-
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
173-
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
174-
username = project.findProperty("gpr.ossrhUser")?.toString() ?: System.getenv("OSSRHUSER")
175-
password = project.findProperty("gpr.ossrhPassword")?.toString() ?: System.getenv("OSSRHPASSWORD")
134+
developers {
135+
developer {
136+
id = "deen13"
137+
name = "Dennis Dierkes"
138+
139+
}
140+
developer {
141+
id = "rubengees"
142+
name = "Ruben Gees"
143+
144+
}
145+
}
146+
scm {
147+
url = "https://github.com/SmartsquareGmbH/mqtt-starter"
148+
connection = "scm:git:https://github.com/SmartsquareGmbH/mqtt-starter.git"
149+
developerConnection = "scm:git:ssh://github.com/SmartsquareGmbH/mqtt-starter.git"
150+
}
151+
organization {
152+
name = "Smartsquare GmbH"
153+
url = "https://github.com/SmartsquareGmbH"
154+
}
155+
issueManagement {
156+
system = "GitHub"
157+
url = "https://github.com/SmartsquareGmbH/mqtt-starter/issues"
176158
}
177-
}
178-
}
179-
180-
signing {
181-
if (!version.toString().endsWith("SNAPSHOT")) {
182-
val signingKey = findProperty("signingKey")?.toString() ?: System.getenv("GPG_PRIVATE_KEY")
183-
val signingPassword = findProperty("signingPassword")?.toString() ?: System.getenv("GPG_PASSPHRASE")
184-
useInMemoryPgpKeys(signingKey, signingPassword)
185-
sign(publishing.publications)
186159
}
187160
}
188161

0 commit comments

Comments
 (0)