@@ -5,7 +5,7 @@ plugins {
55}
66
77group " io.github.jamsesso"
8- version " 1.0.8 -SNAPSHOT"
8+ version " 1.0.9 -SNAPSHOT"
99
1010sourceCompatibility = 1.8
1111targetCompatibility = 1.8
@@ -29,25 +29,51 @@ task sourcesJar(type: Jar) {
2929 from sourceSets. main. allSource
3030}
3131
32+ test {
33+ testLogging {
34+ events " passed" , " skipped" , " failed"
35+ exceptionFormat " full"
36+ showStandardStreams = true
37+ }
38+ }
39+
3240artifacts {
3341 archives jar, javadocJar, sourcesJar
3442}
3543
44+ def getSonatypeUsername () {
45+ return System . getenv(' SONATYPE_USERNAME' )
46+ }
47+
48+ def getSonatypePassword () {
49+ return System . getenv(' SONATYPE_PASSWORD' )
50+ }
51+
52+ def hasCredentials () {
53+ def result = getSonatypeUsername() != null && getSonatypePassword() != null
54+ if (! result) {
55+ println " Cannot publish package since Sonatype credentials are not set. Please set SONATYPE_USERNAME and SONATYPE_PASSWORD environment variables."
56+ }
57+ return result
58+ }
59+
3660signing {
61+ required { gradle. taskGraph. hasTask(" uploadArchives" ) }
62+ useInMemoryPgpKeys(System . getenv(' SIGNING_KEY' ), System . getenv(' SIGNING_PASSWORD' ))
3763 sign configurations. archives
3864}
3965
4066uploadArchives {
4167 repositories {
4268 mavenDeployer {
43- beforeDeployment { MavenDeployment deployment -> signing. signPom(deployment) }
69+ beforeDeployment { deployment -> signing. signPom(deployment) }
4470
4571 repository(url : " https://oss.sonatype.org/service/local/staging/deploy/maven2/" ) {
46- authentication(userName : sonatypeUsername , password : sonatypePassword )
72+ authentication(userName : getSonatypeUsername() , password : getSonatypePassword() )
4773 }
4874
4975 snapshotRepository(url : " https://oss.sonatype.org/content/repositories/snapshots/" ) {
50- authentication(userName : sonatypeUsername , password : sonatypePassword )
76+ authentication(userName : getSonatypeUsername() , password : getSonatypePassword() )
5177 }
5278
5379 pom. project {
@@ -80,4 +106,5 @@ uploadArchives {
80106 }
81107 }
82108 }
109+ onlyIf { hasCredentials() }
83110}
0 commit comments