Skip to content

Commit 39fe403

Browse files
authored
Added nexus publishing block (#222)
2 parents 1e21c7e + a6cdbb0 commit 39fe403

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

.github/actions/maven-publish/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ runs:
3535

3636
- name: Publish Java Packages to Maven
3737
shell: bash
38-
run: ./gradlew publish -PisSnapshot=false --stacktrace
38+
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -PisSnapshot=false --stacktrace
3939
env:
4040
JAVA_HOME: ${{ env.JAVA_HOME }}
4141
MAVEN_USERNAME: ${{ inputs.ossr-username }}

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ plugins {
1313
id 'java'
1414
id 'jacoco'
1515
id 'me.champeau.gradle.japicmp' version '0.2.9'
16+
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
1617
}
1718

1819
jacoco {

gradle/maven-publish.gradle

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,18 @@ artifacts {
2626
}
2727

2828

29-
final releaseRepositoryUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
30-
final snapshotRepositoryUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
31-
3229
publishing {
3330
publications {
3431
mavenJava(MavenPublication) {
32+
from components.java
33+
34+
artifact sourcesJar
35+
artifact javadocJar
3536

3637
groupId = GROUP
3738
artifactId = POM_ARTIFACT_ID
3839
version = getVersionName()
3940

40-
artifact("$buildDir/libs/${project.name}-${version}.jar")
41-
artifact sourcesJar
42-
artifact javadocJar
43-
4441
pom {
4542
name = POM_NAME
4643
packaging = POM_PACKAGING
@@ -82,14 +79,15 @@ publishing {
8279
}
8380
}
8481
}
82+
}
83+
84+
nexusPublishing {
8585
repositories {
86-
maven {
87-
name = "sonatype"
88-
url = version.endsWith('SNAPSHOT') ? snapshotRepositoryUrl : releaseRepositoryUrl
89-
credentials {
90-
username = System.getenv("MAVEN_USERNAME")
91-
password = System.getenv("MAVEN_PASSWORD")
92-
}
86+
sonatype {
87+
nexusUrl.set(uri('https://ossrh-staging-api.central.sonatype.com/service/local/'))
88+
snapshotRepositoryUrl.set(uri('https://central.sonatype.com/repository/maven-snapshots/'))
89+
username.set(System.getenv("MAVEN_USERNAME"))
90+
password.set(System.getenv("MAVEN_PASSWORD"))
9391
}
9492
}
9593
}

0 commit comments

Comments
 (0)