Replace nexus publish plugin with gradle-maven-publish-plugin (#3947)

This commit is contained in:
Bart Louwers
2025-11-14 21:00:57 +00:00
committed by GitHub
parent 3effa43192
commit 3094b283d1
5 changed files with 34 additions and 56 deletions

View File

@@ -127,28 +127,20 @@ jobs:
platform/android/MapLibreAndroid/build/outputs/aar/MapLibreAndroid-${{ matrix.RENDERER }}-${{ env.buildtype }}-${{ needs.android-create-release.outputs.version_tag }}.aar
platform/android/build/debug-symbols-maplibre-android-${{ matrix.RENDERER }}-${{ env.buildtype }}-${{ needs.android-create-release.outputs.version_tag }}.tar.gz
- name: Prepare MavenCentral release
env:
GPG_KEY_CONTENTS: ${{ secrets.GPG_KEY_CONTENTS }}
run: |
echo "${GPG_KEY_CONTENTS}" | base64 -d > signing-key.gpg
shell: bash
- name: Publish to MavenCentral
run: |
renderer=${{ matrix.RENDERER }}
if [ "$renderer" = "opengl" ]; then
./gradlew :MapLibreAndroid:publishOpengl${{ env.buildtype }}PublicationToSonatypeRepository
./gradlew :MapLibreAndroid:publishDefault${{ env.buildtype }}PublicationToSonatypeRepository
./gradlew :MapLibreAndroid:publishOpengl${{ env.buildtype }}PublicationToMavenCentralRepository
./gradlew :MapLibreAndroid:publishDefault${{ env.buildtype }}PublicationToMavenCentralRepository
else
./gradlew :MapLibreAndroid:publishVulkan${{ env.buildtype }}PublicationToSonatypeRepository
./gradlew :MapLibreAndroid:publishVulkan${{ env.buildtype }}PublicationToMavenCentralRepository
fi
env:
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
finilize-release:
runs-on: ubuntu-latest
@@ -170,13 +162,9 @@ jobs:
distribution: "temurin"
java-version: "17"
- name: Close Sonatype staging repository
run: ./gradlew closeSonatypeStagingRepository
working-directory: platform/android
env:
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v4
with:
node-version-file: ".nvmrc"
- run: npm install
working-directory: .

View File

@@ -1,21 +1,6 @@
plugins {
alias(libs.plugins.nexusPublishPlugin)
alias(libs.plugins.kotlinter) apply false
alias(libs.plugins.kotlinAndroid) apply false
id("com.jaredsburrows.license") version "0.9.8" apply false
id("maplibre.dependencies")
id("maplibre.publish-root")
}
nexusPublishing {
repositories {
sonatype {
stagingProfileId.set(extra["sonatypeStagingProfileId"] as String?)
username.set(extra["mavenCentralUsername"] as String?)
password.set(extra["mavenCentralPassword"] as String?)
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
}
}
}

View File

@@ -11,6 +11,7 @@ repositories {
dependencies {
implementation("com.vanniktech:gradle-dependency-graph-generator-plugin:0.3.0")
implementation("com.vanniktech:gradle-maven-publish-plugin:0.34.0")
implementation("com.android.tools.build:gradle:8.6.0")
implementation("com.android.application:com.android.application.gradle.plugin:8.6.0")
implementation("commons-collections:commons-collections:3.2.2")

View File

@@ -1,3 +1,4 @@
import org.gradle.api.Task
import org.gradle.kotlin.dsl.get
import java.util.Locale
@@ -5,8 +6,29 @@ plugins {
`maven-publish`
signing
id("com.android.library")
id("com.vanniktech.maven.publish.base")
id("maplibre.artifact-settings")
id("maplibre.publish-root")
}
afterEvaluate {
mavenPublishing {
publishToMavenCentral()
signAllPublications()
}
}
// Configure task dependencies after all tasks are created
gradle.projectsEvaluated {
// Explicitly configure publish tasks to depend on their corresponding signing tasks
// This fixes Gradle's implicit dependency validation warnings
// Since some publications may share components (e.g., defaultdebug and opengldebug both use openglDebug),
// we ensure all signing tasks complete before any publish task
tasks.filter { it.name.startsWith("publish") && it.name.endsWith("PublicationToMavenCentralRepository") }.forEach { publishTask ->
tasks.filter { it.name.startsWith("sign") && it.name.endsWith("Publication") }.forEach { signingTask ->
publishTask.dependsOn(signingTask)
}
}
}
tasks.register<Javadoc>("androidJavadocs") {
@@ -89,14 +111,6 @@ fun configureMavenPublication(
}
// workaround for https://github.com/gradle/gradle/issues/26091#issuecomment-1836156762
// https://github.com/gradle-nexus/publish-plugin/issues/208
tasks {
withType<PublishToMavenRepository> {
dependsOn(withType<Sign>())
}
}
afterEvaluate {
configureMavenPublication("opengl", "defaultrelease", "", "")
configureMavenPublication("opengl", "defaultdebug", "-debug", " (Debug)", "Debug")
@@ -119,7 +133,3 @@ afterEvaluate {
}
}
}
signing {
sign(publishing.publications)
}

View File

@@ -1,6 +0,0 @@
extra["signing.keyId"] = System.getenv("SIGNING_KEY_ID")
extra["signing.password"] = System.getenv("SIGNING_PASSWORD")
extra["signing.secretKeyRingFile"] = "${projectDir}/../signing-key.gpg"
extra["mavenCentralUsername"] = System.getenv("MAVEN_CENTRAL_USERNAME")
extra["mavenCentralPassword"] = System.getenv("MAVEN_CENTRAL_PASSWORD")
extra["sonatypeStagingProfileId"] = System.getenv("SONATYPE_STAGING_PROFILE_ID")