Skip to content

Commit 3094b28

Browse files
authored
Replace nexus publish plugin with gradle-maven-publish-plugin (#3947)
1 parent 3effa43 commit 3094b28

5 files changed

Lines changed: 34 additions & 56 deletions

File tree

.github/workflows/android-release.yml

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -127,28 +127,20 @@ jobs:
127127
platform/android/MapLibreAndroid/build/outputs/aar/MapLibreAndroid-${{ matrix.RENDERER }}-${{ env.buildtype }}-${{ needs.android-create-release.outputs.version_tag }}.aar
128128
platform/android/build/debug-symbols-maplibre-android-${{ matrix.RENDERER }}-${{ env.buildtype }}-${{ needs.android-create-release.outputs.version_tag }}.tar.gz
129129
130-
- name: Prepare MavenCentral release
131-
env:
132-
GPG_KEY_CONTENTS: ${{ secrets.GPG_KEY_CONTENTS }}
133-
run: |
134-
echo "${GPG_KEY_CONTENTS}" | base64 -d > signing-key.gpg
135-
shell: bash
136-
137130
- name: Publish to MavenCentral
138131
run: |
139132
renderer=${{ matrix.RENDERER }}
140133
if [ "$renderer" = "opengl" ]; then
141-
./gradlew :MapLibreAndroid:publishOpengl${{ env.buildtype }}PublicationToSonatypeRepository
142-
./gradlew :MapLibreAndroid:publishDefault${{ env.buildtype }}PublicationToSonatypeRepository
134+
./gradlew :MapLibreAndroid:publishOpengl${{ env.buildtype }}PublicationToMavenCentralRepository
135+
./gradlew :MapLibreAndroid:publishDefault${{ env.buildtype }}PublicationToMavenCentralRepository
143136
else
144-
./gradlew :MapLibreAndroid:publishVulkan${{ env.buildtype }}PublicationToSonatypeRepository
137+
./gradlew :MapLibreAndroid:publishVulkan${{ env.buildtype }}PublicationToMavenCentralRepository
145138
fi
146139
env:
147-
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
148-
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
149-
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
150-
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
151-
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
140+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
141+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
142+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_PRIVATE_KEY }}
143+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
152144

153145
finilize-release:
154146
runs-on: ubuntu-latest
@@ -170,13 +162,9 @@ jobs:
170162
distribution: "temurin"
171163
java-version: "17"
172164

173-
- name: Close Sonatype staging repository
174-
run: ./gradlew closeSonatypeStagingRepository
175-
working-directory: platform/android
176-
env:
177-
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
178-
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
179-
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
165+
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v4
166+
with:
167+
node-version-file: ".nvmrc"
180168

181169
- run: npm install
182170
working-directory: .

platform/android/build.gradle.kts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
plugins {
2-
alias(libs.plugins.nexusPublishPlugin)
32
alias(libs.plugins.kotlinter) apply false
43
alias(libs.plugins.kotlinAndroid) apply false
54
id("com.jaredsburrows.license") version "0.9.8" apply false
65
id("maplibre.dependencies")
7-
id("maplibre.publish-root")
8-
}
9-
10-
11-
nexusPublishing {
12-
repositories {
13-
sonatype {
14-
stagingProfileId.set(extra["sonatypeStagingProfileId"] as String?)
15-
username.set(extra["mavenCentralUsername"] as String?)
16-
password.set(extra["mavenCentralPassword"] as String?)
17-
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
18-
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
19-
}
20-
}
216
}

platform/android/buildSrc/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ repositories {
1111

1212
dependencies {
1313
implementation("com.vanniktech:gradle-dependency-graph-generator-plugin:0.3.0")
14+
implementation("com.vanniktech:gradle-maven-publish-plugin:0.34.0")
1415
implementation("com.android.tools.build:gradle:8.6.0")
1516
implementation("com.android.application:com.android.application.gradle.plugin:8.6.0")
1617
implementation("commons-collections:commons-collections:3.2.2")

platform/android/buildSrc/src/main/kotlin/maplibre.gradle-publish.gradle.kts

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,34 @@
1+
import org.gradle.api.Task
12
import org.gradle.kotlin.dsl.get
23
import java.util.Locale
34

45
plugins {
56
`maven-publish`
67
signing
78
id("com.android.library")
9+
id("com.vanniktech.maven.publish.base")
810
id("maplibre.artifact-settings")
9-
id("maplibre.publish-root")
11+
}
12+
13+
14+
afterEvaluate {
15+
mavenPublishing {
16+
publishToMavenCentral()
17+
signAllPublications()
18+
}
19+
}
20+
21+
// Configure task dependencies after all tasks are created
22+
gradle.projectsEvaluated {
23+
// Explicitly configure publish tasks to depend on their corresponding signing tasks
24+
// This fixes Gradle's implicit dependency validation warnings
25+
// Since some publications may share components (e.g., defaultdebug and opengldebug both use openglDebug),
26+
// we ensure all signing tasks complete before any publish task
27+
tasks.filter { it.name.startsWith("publish") && it.name.endsWith("PublicationToMavenCentralRepository") }.forEach { publishTask ->
28+
tasks.filter { it.name.startsWith("sign") && it.name.endsWith("Publication") }.forEach { signingTask ->
29+
publishTask.dependsOn(signingTask)
30+
}
31+
}
1032
}
1133

1234
tasks.register<Javadoc>("androidJavadocs") {
@@ -89,14 +111,6 @@ fun configureMavenPublication(
89111
}
90112

91113

92-
// workaround for https://github.com/gradle/gradle/issues/26091#issuecomment-1836156762
93-
// https://github.com/gradle-nexus/publish-plugin/issues/208
94-
tasks {
95-
withType<PublishToMavenRepository> {
96-
dependsOn(withType<Sign>())
97-
}
98-
}
99-
100114
afterEvaluate {
101115
configureMavenPublication("opengl", "defaultrelease", "", "")
102116
configureMavenPublication("opengl", "defaultdebug", "-debug", " (Debug)", "Debug")
@@ -119,7 +133,3 @@ afterEvaluate {
119133
}
120134
}
121135
}
122-
123-
signing {
124-
sign(publishing.publications)
125-
}

platform/android/buildSrc/src/main/kotlin/maplibre.publish-root.gradle.kts

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)