Skip to content

Commit

Permalink
Add artifact signing and Maven Central publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
tsjensen committed Mar 5, 2025
1 parent 431f9fc commit 42f9eb8
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
id 'jacoco'
id 'idea'
id 'checkstyle'
id 'signing'
id 'maven-publish'
id 'org.ajoberstar.grgit' version '4.1.1'
id 'org.barfuin.gradle.jacocolog' version '3.1.0'
Expand Down Expand Up @@ -273,6 +274,16 @@ publishing {
name = 'localBuildDir'
url = project.layout.buildDirectory.dir('maven-repo-test')
}
if (project.hasProperty('SB_SONATYPE_USER') && project.hasProperty('SB_SONATYPE_PASSWORD')) {
maven {
name = 'mavenCentralStaging'
url = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
credentials {
username = project.getProperty('SB_SONATYPE_USER')
password = project.getProperty('SB_SONATYPE_PASSWORD')
}
}
}
}
publications {
mavenJava(MavenPublication) {
Expand All @@ -287,7 +298,7 @@ publishing {
license {
name = 'MIT'
url = 'https://raw.githubusercontent.com/siemens/standard-bom-java/refs/tags/' +
project.version + '/LICENSE'
project.version + '/LICENSE'
}
}
developers {
Expand All @@ -306,3 +317,17 @@ publishing {
}
}
}

if (!Boolean.parseBoolean(System.getenv('CI')) || project.hasProperty('signingKey')) {
signing {
if (Boolean.parseBoolean(System.getenv('CI'))) {
def signingKey = project.getProperty('signingKey')
def signingPassword = project.getProperty('signingPassword')
useInMemoryPgpKeys(signingKey, signingPassword)
}
else {
useGpgCmd() // use local GPG installation and agent
}
sign publishing.publications.mavenJava
}
}

0 comments on commit 42f9eb8

Please sign in to comment.