Skip to content

Commit 3ea601a

Browse files
committed
Use io.github.gradle-nexus.publish-plugin to publish plugin
1 parent 41d992f commit 3ea601a

File tree

1 file changed

+25
-38
lines changed

1 file changed

+25
-38
lines changed

build.gradle

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,25 @@
99
plugins {
1010
// Apply the java-library plugin to add support for Java Library
1111
id 'java-library'
12-
id 'maven-publish'
13-
id 'signing'
12+
1413
id 'jacoco'
1514
id "com.diffplug.spotless" version "6.13.0"
15+
16+
id 'maven-publish'
17+
id 'signing'
18+
// Sonatype Nexus Publish Plugin
19+
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
1620
}
1721

1822
group = 'com.meilisearch.sdk'
19-
archivesBaseName = 'meilisearch-java'
2023
version = '0.14.5'
2124

2225
java {
2326
sourceCompatibility = JavaVersion.VERSION_1_8
2427
targetCompatibility = JavaVersion.VERSION_1_8
28+
29+
withJavadocJar()
30+
withSourcesJar()
2531
}
2632

2733
jacoco {
@@ -43,10 +49,6 @@ repositories {
4349
mavenCentral()
4450
}
4551

46-
configurations {
47-
testCompile.extendsFrom compileOnly
48-
}
49-
5052
dependencies {
5153
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
5254
implementation 'com.google.code.gson:gson:2.12.1'
@@ -77,19 +79,6 @@ dependencies {
7779
implementation 'com.auth0:java-jwt:4.5.0'
7880
}
7981

80-
task buildJar(type: Jar) {
81-
archiveBaseName = 'meilisearch-java'
82-
from {
83-
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
84-
}
85-
{
86-
exclude 'META-INF/*.SF'
87-
exclude 'META-INF/*.DSA'
88-
exclude 'META-INF/*.RSA'
89-
}
90-
with jar
91-
}
92-
9382
test {
9483
finalizedBy jacocoTestReport
9584
useJUnitPlatform {
@@ -121,11 +110,6 @@ task integrationTest(type: Test) {
121110
}
122111
}
123112

124-
java {
125-
withJavadocJar()
126-
withSourcesJar()
127-
}
128-
129113
publishing {
130114
publications {
131115
mavenJava(MavenPublication) {
@@ -158,19 +142,6 @@ publishing {
158142
}
159143
}
160144
}
161-
repositories {
162-
maven {
163-
name = "CentralPortal"
164-
url = "https://central.sonatype.com/api/v1/publisher/upload"
165-
credentials(HttpHeaderCredentials) {
166-
name = "Authorization"
167-
value = "Bearer ${System.getenv('MAVEN_BEARER')}"
168-
}
169-
authentication {
170-
header(HttpHeaderAuthentication)
171-
}
172-
}
173-
}
174145
}
175146

176147
signing {
@@ -192,3 +163,19 @@ spotless {
192163
googleJavaFormat('1.7').aosp()
193164
}
194165
}
166+
167+
168+
// Nexus Publish Plugin configuration
169+
nexusPublishing {
170+
packageGroup.set("com.meilisearch")
171+
172+
repositories {
173+
sonatype {
174+
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
175+
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
176+
177+
username.set(System.getenv('MAVEN_CENTRAL_USERNAME'))
178+
password.set(System.getenv('MAVEN_CENTRAL_PASSWORD'))
179+
}
180+
}
181+
}

0 commit comments

Comments
 (0)