Skip to content

Commit

Permalink
Configure maven central publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
kaklakariada committed Sep 7, 2024
1 parent fdd3e2b commit 27e235e
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id "java-library"
id "signing"
id "maven-publish"
id "io.github.gradle-nexus.publish-plugin" version "2.0.0"
}

java {
Expand All @@ -17,14 +18,6 @@ dependencies {
testImplementation libs.bundles.testUtils
}

def getOptionalProperty(String name) {
if(project.hasProperty(name)) {
return project.property(name)
}
logger.info("Project property '${name}' not available. Please add it to ~/.gradle/gradle.properties")
return null
}

publishing {
publications {
mavenJava(MavenPublication) {
Expand Down Expand Up @@ -56,21 +49,20 @@ publishing {
}
}
}

repositories {
maven {
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
allowInsecureProtocol = false
credentials(PasswordCredentials) {
username = getOptionalProperty("ossrhUsername")
password = getOptionalProperty("ossrhPassword")
}
}
}
}

signing {
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
}

nexusPublishing {
packageGroup = project.group
repositories {
sonatype {
stagingProfileId = "546ea6ce74787e"
}
}
}

0 comments on commit 27e235e

Please sign in to comment.