Skip to content

Commit

Permalink
switch to new sonatype deployment (central)
Browse files Browse the repository at this point in the history
  • Loading branch information
scrayos committed Mar 15, 2024
1 parent d4bb033 commit da97d35
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 44 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ jobs:
- name: Publish package
run: ./gradlew dokkaHtml publish
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SCRAYOSNET_GPG_MEMORYKEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SCRAYOSNET_GPG_PASSWORD }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Pages
Expand Down
76 changes: 34 additions & 42 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@file:Suppress("UnstableApiUsage")

import com.google.protobuf.gradle.id
import org.gradle.internal.impldep.org.bouncycastle.cms.RecipientId.password
import com.vanniktech.maven.publish.SonatypeHost
import org.jlleitschuh.gradle.ktlint.reporter.ReporterType

// define the gav coordinates of this project
Expand All @@ -17,7 +17,7 @@ plugins {
alias(libs.plugins.kotlin)
alias(libs.plugins.dokka)
alias(libs.plugins.kover)
alias(libs.plugins.nexusPublish)
id("com.vanniktech.maven.publish") version "0.28.0"
alias(libs.plugins.protobuf)
alias(libs.plugins.sonarqube)
alias(libs.plugins.ktlint)
Expand Down Expand Up @@ -51,12 +51,6 @@ dependencies {
dokkaHtmlPlugin(libs.dokka.html)
}

// configure the java extension
java {
// also generate javadoc and sources
withSourcesJar()
}

// configure the kotlin extension
kotlin {
// set the toolchain version that is required to build this project
Expand Down Expand Up @@ -114,33 +108,40 @@ testing {
}
}

// configure dokka task for html output
val dokkaHtmlJar = tasks.register<Jar>("dokkaHtmlJar") {
description = "Generates the HTML documentation for this project."
group = JavaBasePlugin.DOCUMENTATION_GROUP
dependsOn(tasks.dokkaHtml)
from(tasks.dokkaHtml.flatMap { it.outputDirectory })
archiveClassifier.set("html-docs")
}

// configure dokka task for javadoc output
val dokkaJavadocJar = tasks.register<Jar>("dokkaJavadocJar") {
description = "Generates the Javadoc documentation for this project."
group = JavaBasePlugin.DOCUMENTATION_GROUP
dependsOn(tasks.dokkaJavadoc)
from(tasks.dokkaJavadoc.flatMap { it.outputDirectory })
archiveClassifier.set("javadoc")
}

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 = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_PASSWORD")
// configure publishing for the sonatype portal
mavenPublishing {
// add the central portal of Sonatype
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, automaticRelease = true)

// configure mandatory metadata for Maven Central
pom {
name.set("xenos-client (Kotlin)")
description.set("A gRPC client/binding for the communication with xenos.")
inceptionYear.set("2024")
url.set("https://github.com/scrayosnet/xenos-client-kotlin/")
licenses {
license {
name.set("MIT License")
url.set("https://opensource.org/license/mit")
distribution.set("repo")
}
}
developers {
developer {
id.set("scrayos")
name.set("Joshua Dean Küpper")
url.set("https://github.com/scrayos/")
}
}
scm {
url.set("https://github.com/scrayosnet/xenos-client-kotlin/")
connection.set("scm:git:git://github.com/scrayosnet/xenos-client-kotlin.git")
developerConnection.set("scm:git:ssh://[email protected]/scrayosnet/xenos-client-kotlin.git")
}
}

// sign all exported publications
signAllPublications()
}

// configure the publishing in the maven repository
Expand All @@ -156,15 +157,6 @@ publishing {
}
}
}

// define the java components as publications for the repository
publications {
create<MavenPublication>("maven") {
from(components["java"])
artifact(dokkaJavadocJar)
artifact(dokkaHtmlJar)
}
}
}

// configure ktlint
Expand Down

0 comments on commit da97d35

Please sign in to comment.