From 1b4a347e8b16ec6de575d673f74d3ee0804e95eb Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Sun, 20 Apr 2025 22:20:30 +0200 Subject: [PATCH] Move to new publishing portal (#4630) * Move to new publishing portal Signed-off-by: Alexander Brandes * Use new variables Signed-off-by: Alexander Brandes * Try snapshot Signed-off-by: Alexander Brandes * Back to main Signed-off-by: Alexander Brandes --------- Signed-off-by: Alexander Brandes --- .github/workflows/build.yml | 12 ++-- build.gradle.kts | 134 ++++++++++++++++-------------------- gradle/libs.versions.toml | 4 +- 3 files changed, 68 insertions(+), 82 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6d09b36bb..017e23ee8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,18 +29,18 @@ jobs: fi - name: Publish Release if: ${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'push' && github.ref == 'refs/heads/main'}} - run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository + run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache env: - ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }} - ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }} + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.CENTRAL_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.CENTRAL_PASSWORD }} ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }} ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }} - name: Publish Snapshot if: ${{ runner.os == 'Linux' && env.STATUS != 'release' && github.event_name == 'push' && github.ref == 'refs/heads/main' }} - run: ./gradlew publishToSonatype + run: ./gradlew publishAllPublicationsToMavenCentralRepository env: - ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }} - ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }} + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.CENTRAL_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.CENTRAL_PASSWORD }} - name: Publish core javadoc if: ${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'push' && github.ref == 'refs/heads/main'}} uses: cpina/github-action-push-to-another-repository@main diff --git a/build.gradle.kts b/build.gradle.kts index 358aaa98a..000acd1de 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,6 @@ import com.diffplug.gradle.spotless.SpotlessPlugin import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin +import com.vanniktech.maven.publish.SonatypeHost import groovy.json.JsonSlurper import xyz.jpenilla.runpaper.task.RunServer import java.net.URI @@ -7,13 +8,12 @@ import java.net.URI plugins { java `java-library` - `maven-publish` signing alias(libs.plugins.shadow) alias(libs.plugins.spotless) alias(libs.plugins.grgit) - alias(libs.plugins.nexus) + alias(libs.plugins.publish) eclipse idea @@ -68,7 +68,7 @@ subprojects { apply { plugin() plugin() - plugin() + plugin() plugin() plugin() plugin() @@ -107,11 +107,6 @@ subprojects { } } - java { - withSourcesJar() - withJavadocJar() - } - val javaComponent = components["java"] as AdhocComponentWithVariants javaComponent.withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) { skip() @@ -127,66 +122,67 @@ subprojects { } } - publishing { - publications { - create("maven") { - from(components["java"]) + mavenPublishing { + coordinates( + groupId = "$group", + artifactId = project.name, + version = "${project.version}", + ) - pom { + pom { + name.set(project.name) + description.set("PlotSquared, a land and world management plugin for Minecraft.") + url.set("https://github.com/IntellectualSites/PlotSquared") - name.set(project.name + " " + project.version) - description.set("PlotSquared, a land and world management plugin for Minecraft.") - url.set("https://github.com/IntellectualSites/PlotSquared") - - licenses { - license { - name.set("GNU General Public License, Version 3.0") - url.set("https://www.gnu.org/licenses/gpl-3.0.html") - distribution.set("repo") - } - } - - developers { - developer { - id.set("Sauilitired") - name.set("Alexander Söderberg") - organization.set("IntellectualSites") - organizationUrl.set("https://github.com/IntellectualSites") - } - developer { - id.set("NotMyFault") - name.set("Alexander Brandes") - organization.set("IntellectualSites") - organizationUrl.set("https://github.com/IntellectualSites") - email.set("contact(at)notmyfault.dev") - } - developer { - id.set("SirYwell") - name.set("Hannes Greule") - organization.set("IntellectualSites") - organizationUrl.set("https://github.com/IntellectualSites") - } - developer { - id.set("dordsor21") - name.set("dordsor21") - organization.set("IntellectualSites") - organizationUrl.set("https://github.com/IntellectualSites") - } - } - - scm { - url.set("https://github.com/IntellectualSites/PlotSquared") - connection.set("scm:git:https://github.com/IntellectualSites/PlotSquared.git") - developerConnection.set("scm:git:git@github.com:IntellectualSites/PlotSquared.git") - tag.set("${project.version}") - } - - issueManagement { - system.set("GitHub") - url.set("https://github.com/IntellectualSites/PlotSquared/issues") - } + licenses { + license { + name.set("GNU General Public License, Version 3.0") + url.set("https://www.gnu.org/licenses/gpl-3.0.html") + distribution.set("repo") } } + + developers { + developer { + id.set("Sauilitired") + name.set("Alexander Söderberg") + organization.set("IntellectualSites") + organizationUrl.set("https://github.com/IntellectualSites") + } + developer { + id.set("NotMyFault") + name.set("Alexander Brandes") + organization.set("IntellectualSites") + organizationUrl.set("https://github.com/IntellectualSites") + email.set("contact(at)notmyfault.dev") + } + developer { + id.set("SirYwell") + name.set("Hannes Greule") + organization.set("IntellectualSites") + organizationUrl.set("https://github.com/IntellectualSites") + } + developer { + id.set("dordsor21") + name.set("dordsor21") + organization.set("IntellectualSites") + organizationUrl.set("https://github.com/IntellectualSites") + } + } + + scm { + url.set("https://github.com/IntellectualSites/PlotSquared") + connection.set("scm:git:https://github.com/IntellectualSites/PlotSquared.git") + developerConnection.set("scm:git:git@github.com:IntellectualSites/PlotSquared.git") + tag.set("${project.version}") + } + + issueManagement { + system.set("GitHub") + url.set("https://github.com/IntellectualSites/PlotSquared/issues") + } + + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) } } @@ -194,7 +190,6 @@ subprojects { compileJava { options.compilerArgs.add("-parameters") - options.isDeprecation = true options.encoding = "UTF-8" } @@ -217,15 +212,6 @@ subprojects { } } -nexusPublishing { - this.repositories { - sonatype { - nexusUrl.set(URI.create("https://s01.oss.sonatype.org/service/local/")) - snapshotRepositoryUrl.set(URI.create("https://s01.oss.sonatype.org/content/repositories/snapshots/")) - } - } -} - tasks.getByName("jar") { enabled = false } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3ecfb179f..c6c087ea0 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -36,7 +36,7 @@ serverlib = "2.3.7" shadow = "8.3.6" grgit = "4.1.1" spotless = "7.0.3" -nexus = "2.0.0" +publish = "0.31.0" runPaper = "2.3.1" [libraries] @@ -81,5 +81,5 @@ serverlib = { group = "dev.notmyfault.serverlib", name = "ServerLib", version.re shadow = { id = "com.gradleup.shadow", version.ref = "shadow" } grgit = { id = "org.ajoberstar.grgit", version.ref = "grgit" } spotless = { id = "com.diffplug.spotless", version.ref = "spotless" } -nexus = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexus" } +publish = { id = "com.vanniktech.maven.publish", version.ref = "publish" } runPaper = { id = "xyz.jpenilla.run-paper", version.ref = "runPaper" }