Skip to content

Commit 203e542

Browse files
zeevmoneyclaude
andcommitted
Migrate to new Maven Central Portal for publishing
- Upgrade Gradle from 7.3.3 to 8.5 for plugin compatibility - Replace legacy nexus-publish plugin with vanniktech/gradle-maven-publish-plugin - Configure Maven Central Portal publishing (CENTRAL_PORTAL host) - Update workflows to use Java 11 for building - Update GitHub Actions to v4 versions - Use standard Gradle project properties for credentials: - ORG_GRADLE_PROJECT_mavenCentralUsername - ORG_GRADLE_PROJECT_mavenCentralPassword - ORG_GRADLE_PROJECT_signingInMemoryKey - ORG_GRADLE_PROJECT_signingInMemoryKeyPassword Required secrets (generate from https://central.sonatype.com/account): - MAVEN_CENTRAL_USERNAME: Username from token generation - MAVEN_CENTRAL_PASSWORD: Password from token generation Fixes PER-13671 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent bd2806c commit 203e542

4 files changed

Lines changed: 62 additions & 75 deletions

File tree

.github/workflows/javadoc.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,18 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v4
14-
- uses: actions/setup-java@v3.11.0
1514
with:
16-
java-version: '8'
15+
fetch-depth: 0 # Required for git-version plugin
16+
- uses: actions/setup-java@v4
17+
with:
18+
java-version: '11'
1719
distribution: 'corretto'
1820
- name: Validate Gradle wrapper
19-
uses: gradle/wrapper-validation-action@v1
21+
uses: gradle/wrapper-validation-action@v2
22+
- name: Setup Gradle
23+
uses: gradle/actions/setup-gradle@v3
2024
- name: Generate Javadoc
21-
uses: gradle/gradle-build-action@v2
22-
with:
23-
arguments: javadoc
25+
run: ./gradlew javadoc
2426
- name: Check Javadoc generation
2527
run: |
2628
if [ -d "build/docs/javadoc" ]; then

.github/workflows/publish.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
fetch-depth: 0 # Required for git-version plugin
1717
- uses: actions/setup-java@v4
1818
with:
19-
java-version: '8'
19+
java-version: '11'
2020
distribution: 'corretto'
2121
- name: Validate Gradle wrapper
2222
uses: gradle/wrapper-validation-action@v2
@@ -38,8 +38,9 @@ jobs:
3838
GITHUB_ACTOR: ${{ github.actor }}
3939
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4040
- name: Publish to Maven Central
41-
run: ./gradlew publishToMavenCentralPortal
41+
run: ./gradlew publishAndReleaseToMavenCentral
4242
env:
43-
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
44-
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
45-
GPG_SIGNING_PASSPHRASE: ${{ secrets.GPG_SIGNING_PASSPHRASE }}
43+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
44+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
45+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_SIGNING_KEY }}
46+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_SIGNING_PASSPHRASE }}

build.gradle

Lines changed: 47 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@
99
plugins {
1010
// Apply the java-library plugin for API and implementation separation.
1111
id 'java-library'
12-
// Maven publish plugins helps us to publish our library to maven repos
13-
id 'maven-publish'
1412
// the signing plugin helps us to crypto-sign on our package (PGP key)
1513
id 'signing'
1614
// the git-version plugin helps us to publish an auto version (taken from git tags)
1715
id 'com.palantir.git-version' version '0.13.0'
18-
// New Maven Central Portal publishing (replaces legacy OSSRH/Nexus)
19-
id 'tech.yanand.maven-central-publish' version '1.2.0'
16+
// Maven Central Portal publishing (community plugin, recommended by Sonatype)
17+
// See: https://vanniktech.github.io/gradle-maven-publish-plugin/central/
18+
id 'com.vanniktech.maven.publish' version '0.28.0'
2019
// translate json schemas to java classes
2120
// id "org.jsonschema2pojo" version "1.1.3"
2221
}
@@ -147,6 +146,50 @@ dependencies {
147146
// initializeCollections = false
148147
//}
149148

149+
// Maven Central Portal publishing configuration
150+
// See: https://vanniktech.github.io/gradle-maven-publish-plugin/central/
151+
mavenPublishing {
152+
// Publish to Maven Central Portal (new system replacing OSSRH)
153+
publishToMavenCentral(com.vanniktech.maven.publish.SonatypeHost.CENTRAL_PORTAL)
154+
155+
// Sign all publications with GPG
156+
signAllPublications()
157+
158+
// Artifact coordinates
159+
coordinates("io.permit", "permit-sdk-java", version.toString())
160+
161+
// POM configuration required by Maven Central
162+
pom {
163+
name = "Permit.io Java SDK"
164+
description = "Java SDK for Permit.io: fullstack permissions for cloud native applications"
165+
url = "https://permit.io"
166+
inceptionYear = "2021"
167+
168+
licenses {
169+
license {
170+
name = "The Apache License, Version 2.0"
171+
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
172+
distribution = "repo"
173+
}
174+
}
175+
176+
developers {
177+
developer {
178+
id = "asafc"
179+
name = "Asaf Cohen"
180+
email = "asaf@permit.io"
181+
}
182+
}
183+
184+
scm {
185+
connection = "scm:git:git://github.com/permitio/permit-java.git"
186+
developerConnection = "scm:git:ssh://github.com/permitio/permit-java.git"
187+
url = "https://github.com/permitio/permit-java"
188+
}
189+
}
190+
}
191+
192+
// GitHub Packages publishing (separate from Maven Central)
150193
publishing {
151194
repositories {
152195
maven {
@@ -158,65 +201,6 @@ publishing {
158201
}
159202
}
160203
}
161-
162-
publications {
163-
maven(MavenPublication) {
164-
groupId = 'io.permit'
165-
artifactId = 'permit-sdk-java'
166-
167-
from components.java
168-
169-
pom {
170-
name = "Permit.io Java SDK"
171-
description = 'Java SDK for Permit.io: fullstack permissions for cloud native applications'
172-
url = 'https://permit.io'
173-
licenses {
174-
license {
175-
name = 'The Apache License, Version 2.0'
176-
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
177-
}
178-
}
179-
developers {
180-
developer {
181-
id = 'asafc'
182-
name = 'Asaf Cohen'
183-
email = 'asaf@permit.io'
184-
}
185-
}
186-
scm {
187-
connection = 'scm:git:git://github.com/permitio/permit-java.git'
188-
developerConnection = 'scm:git:ssh://github.com/permitio/permit-java.git'
189-
url = 'https://github.com/permitio/permit-java'
190-
}
191-
}
192-
}
193-
}
194-
}
195-
196-
// Maven Central Portal publishing configuration
197-
// See: https://github.com/yananhub/flying-gradle-plugin
198-
mavenCentral {
199-
// Local staging directory where artifacts are collected before upload.
200-
// The plugin publishes JARs, POM, and signatures here first, then zips
201-
// and uploads the bundle to Maven Central Portal.
202-
repoDir = layout.buildDirectory.dir("staging-deploy")
203-
204-
// Authentication token from Maven Central Portal.
205-
// Generate at: https://central.sonatype.com/account -> Generate User Token
206-
// The token is a base64-encoded "username:password" string.
207-
authToken = System.getenv("MAVEN_CENTRAL_TOKEN")
208-
209-
// Publishing mode:
210-
// - "AUTOMATIC": Artifacts are automatically published after validation
211-
// - "USER_MANAGED": Artifacts stay in pending state for manual release
212-
publishingType = "AUTOMATIC"
213-
}
214-
215-
signing {
216-
def GPG_SIGNING_KEY = findProperty("signingKey") ?: System.getenv("GPG_SIGNING_KEY")
217-
def GPG_SIGNING_PASSPHRASE = findProperty("signingPassword") ?: System.getenv("GPG_SIGNING_PASSPHRASE")
218-
useInMemoryPgpKeys(GPG_SIGNING_KEY, GPG_SIGNING_PASSPHRASE)
219-
sign publishing.publications.maven
220204
}
221205

222206
tasks.named('test') {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)