Skip to content

Commit

Permalink
Switch to maven central publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
rubengees committed Sep 1, 2024
1 parent ade03a0 commit edc02d7
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 77 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ jobs:
run: ./gradlew check

- name: Publish
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
run: ./gradlew publishToMavenCentral
env:
OSSRHUSER: ${{ secrets.OSSRHUSER }}
OSSRHPASSWORD: ${{ secrets.OSSRHPASSWORD }}
GITHUB_VERSION: ${{ github.event.release.tag_name }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.GPG_KEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_KEY_PASSWORD }}

- name: Upload Gradle reports
uses: actions/upload-artifact@v4
Expand Down
117 changes: 45 additions & 72 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.KotlinJvm
import com.vanniktech.maven.publish.SonatypeHost
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id("signing")
id("maven-publish")
kotlin("jvm") version "1.9.23"
id("org.jetbrains.kotlin.plugin.spring") version "1.9.23"
id("dev.adamko.dokkatoo-html") version "2.2.0"
id("dev.adamko.dokkatoo-javadoc") version "2.2.0"
id("io.gitlab.arturbosch.detekt") version "1.23.5"
id("org.jmailen.kotlinter") version "4.3.0"
id("com.adarshr.test-logger") version "4.0.0"
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
id("com.vanniktech.maven.publish") version "0.29.0"
id("com.github.ben-manes.versions") version "0.51.0"
}

Expand Down Expand Up @@ -54,9 +55,6 @@ dependencies {
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

withJavadocJar()
withSourcesJar()
}

kotlin {
Expand All @@ -73,10 +71,6 @@ detekt {
buildUponDefaultConfig = true
}

tasks.named<Jar>("javadocJar") {
from(tasks.named("dokkatooGeneratePublicationJavadoc"))
}

dokkatoo {
val jacksonVersion = resolveVersion("com.fasterxml.jackson.core:jackson-core")
val mqttClientVersion = resolveVersion("com.hivemq:hivemq-mqtt-client")
Expand Down Expand Up @@ -118,71 +112,50 @@ fun isNonStable(version: String): Boolean {
return !isStable
}

publishing {
publications {
create<MavenPublication>("maven") {
artifactId = "mqtt-starter"

from(components["java"])

pom {
name = "Mqtt-Starter"
description = "Spring Boot Starter wrapping the hivemq mqtt client."
url = "https://github.com/SmartsquareGmbH/mqtt-starter"

licenses {
license {
name = "MIT License"
url = "https://opensource.org/licenses/MIT"
}
}
developers {
developer {
id = "deen13"
name = "Dennis Dierkes"
email = "[email protected]"
}
developer {
id = "rubengees"
name = "Ruben Gees"
email = "[email protected]"
}
}
scm {
connection = "scm:git:https://github.com/SmartsquareGmbH/mqtt-starter.git"
developerConnection = "scm:git:ssh://github.com/SmartsquareGmbH/mqtt-starter.git"
url = "https://github.com/SmartsquareGmbH/mqtt-starter"
}
organization {
name = "Smartsquare GmbH"
url = "https://github.com/SmartsquareGmbH"
}
issueManagement {
system = "GitHub"
url = "https://github.com/SmartsquareGmbH/mqtt-starter/issues"
}
mavenPublishing {
configure(KotlinJvm(JavadocJar.Dokka("dokkatooGeneratePublicationJavadoc")))

publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, automaticRelease = true)
signAllPublications()

pom {
name = "Mqtt-Starter"
description = "Spring Boot Starter wrapping the hivemq mqtt client."
url = "https://github.com/SmartsquareGmbH/mqtt-starter"
inceptionYear = "2021"

licenses {
license {
name = "MIT License"
url = "https://opensource.org/license/mit"
distribution = "https://opensource.org/license/mit"
}
}
}
}

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 = project.findProperty("gpr.ossrhUser")?.toString() ?: System.getenv("OSSRHUSER")
password = project.findProperty("gpr.ossrhPassword")?.toString() ?: System.getenv("OSSRHPASSWORD")
developers {
developer {
id = "deen13"
name = "Dennis Dierkes"
email = "[email protected]"
}
developer {
id = "rubengees"
name = "Ruben Gees"
email = "[email protected]"
}
}
scm {
url = "https://github.com/SmartsquareGmbH/mqtt-starter"
connection = "scm:git:https://github.com/SmartsquareGmbH/mqtt-starter.git"
developerConnection = "scm:git:ssh://github.com/SmartsquareGmbH/mqtt-starter.git"
}
organization {
name = "Smartsquare GmbH"
url = "https://github.com/SmartsquareGmbH"
}
issueManagement {
system = "GitHub"
url = "https://github.com/SmartsquareGmbH/mqtt-starter/issues"
}
}
}

signing {
if (!version.toString().endsWith("SNAPSHOT")) {
val signingKey = findProperty("signingKey")?.toString() ?: System.getenv("GPG_PRIVATE_KEY")
val signingPassword = findProperty("signingPassword")?.toString() ?: System.getenv("GPG_PASSPHRASE")
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications)
}
}

Expand Down

0 comments on commit edc02d7

Please sign in to comment.