Skip to content

Commit c51ec7b

Browse files
committed
Move to Maven Central via Central Portal
1 parent 6381b7b commit c51ec7b

File tree

3 files changed

+50
-121
lines changed

3 files changed

+50
-121
lines changed

.github/workflows/ossrh-publish.yml

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

.github/workflows/publish.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Publish to Maven Central
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Set up Java
16+
uses: actions/setup-java@v4
17+
with:
18+
java-version: 17
19+
distribution: 'zulu'
20+
cache: gradle
21+
22+
- name: Check release validity
23+
run: bash .github/scripts/check-release.sh
24+
25+
- name: Grant execute permission for gradlew
26+
run: chmod +x gradlew
27+
28+
- name: Publish to Maven Central via Central Portal
29+
run: |
30+
./gradlew --stacktrace \
31+
uploadAllPublicationsToProjectLocalRepository \
32+
zipMavenCentralPortalPublication \
33+
releaseMavenCentralPortalPublication
34+
env:
35+
MAVEN_CENTRAL_PORTAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
36+
MAVEN_CENTRAL_PORTAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
37+
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }}
38+
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}

build.gradle

Lines changed: 12 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77
*/
88

99
plugins {
10-
// Apply the java-library plugin to add support for Java Library
1110
id 'java-library'
1211
id 'maven-publish'
1312
id 'signing'
13+
id 'org.danilopianini.publish-on-central' version "8.0.7"
1414
id 'jacoco'
15-
id 'io.github.gradle-nexus.publish-plugin' version "2.0.0"
1615
id "com.diffplug.spotless" version "6.13.0"
1716
}
1817

@@ -23,6 +22,8 @@ version = '0.14.5'
2322
java {
2423
sourceCompatibility = JavaVersion.VERSION_1_8
2524
targetCompatibility = JavaVersion.VERSION_1_8
25+
withJavadocJar()
26+
withSourcesJar()
2627
}
2728

2829
jacoco {
@@ -44,10 +45,6 @@ repositories {
4445
mavenCentral()
4546
}
4647

47-
configurations {
48-
testCompile.extendsFrom compileOnly
49-
}
50-
5148
dependencies {
5249
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
5350
implementation 'com.google.code.gson:gson:2.12.1'
@@ -78,19 +75,6 @@ dependencies {
7875
implementation 'com.auth0:java-jwt:4.5.0'
7976
}
8077

81-
task buildJar(type: Jar) {
82-
archiveBaseName = 'meilisearch-java'
83-
from {
84-
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
85-
}
86-
{
87-
exclude 'META-INF/*.SF'
88-
exclude 'META-INF/*.DSA'
89-
exclude 'META-INF/*.RSA'
90-
}
91-
with jar
92-
}
93-
9478
test {
9579
finalizedBy jacocoTestReport
9680
useJUnitPlatform {
@@ -122,70 +106,18 @@ task integrationTest(type: Test) {
122106
}
123107
}
124108

125-
java {
126-
withJavadocJar()
127-
withSourcesJar()
128-
}
129-
130-
publishing {
131-
publications {
132-
mavenJava(MavenPublication) {
133-
artifactId = 'meilisearch-java'
134-
from components.java
135-
pom {
136-
name = 'com.meilisearch.sdk:meilisearch-java'
137-
packaging = 'jar'
138-
artifactId = 'meilisearch-java'
139-
description = 'Meilisearch is a powerful, fast, open-source, easy to use and deploy search engine.'
140-
url = 'https://github.com/meilisearch/meilisearch-java'
141-
scm {
142-
connection = 'scm:git:git://github.com/meilisearch/meilisearch-java.git'
143-
developerConnection = 'scm:git:ssh://github.com:meilisearch/meilisearch-java.git'
144-
url = 'http://github.com/meilisearch/meilisearch-java'
145-
}
146-
licenses {
147-
license {
148-
name = 'MIT License'
149-
url = 'http://www.opensource.org/licenses/mit-license.php'
150-
}
151-
}
152-
developers {
153-
developer {
154-
id = 'eskombro'
155-
name = 'Samuel Jimenez'
156-
157-
}
158-
}
159-
}
160-
}
161-
}
162-
repositories {
163-
maven {
164-
url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
165-
credentials {
166-
username System.getenv('OSSRH_USERNAME')
167-
password System.getenv('OSSRH_PASSWORD')
168-
}
169-
}
170-
}
171-
}
172-
173-
nexusPublishing {
174-
packageGroup = "com.meilisearch"
175-
176-
repositories {
177-
sonatype {
178-
nexusUrl.set(uri("https://oss.sonatype.org/service/local/"))
179-
180-
username = System.getenv('OSSRH_USERNAME')
181-
password = System.getenv('OSSRH_PASSWORD')
182-
stagingProfileId = System.getenv('SONATYPE_STAGING_PROFILE_ID')
183-
}
184-
}
109+
// New Maven Central Portal publishing configuration
110+
publishOnCentral {
111+
repoOwner.set("meilisearch")
112+
projectDescription.set("Meilisearch Java SDK")
113+
projectUrl.set("https://github.com/meilisearch/meilisearch-java")
185114
}
186115

187116
signing {
188-
sign publishing.publications.mavenJava
117+
useInMemoryPgpKeys(
118+
findProperty("signingKey")?.toString(),
119+
findProperty("signingPassword")?.toString()
120+
)
189121
}
190122

191123
javadoc {

0 commit comments

Comments
 (0)