@@ -9,8 +9,6 @@ apply from: rootProject.file( 'gradle/releasable.gradle' )
99apply from : rootProject. file( ' gradle/java-module.gradle' )
1010apply from : rootProject. file( ' gradle/publishing-pom.gradle' )
1111
12- apply plugin : ' signing'
13-
1412// Make sure that the publishReleaseArtifacts task of the release module runs the release task of this sub module
1513tasks. getByPath( ' :release:publishReleaseArtifacts' ). dependsOn tasks. release
1614
@@ -98,6 +96,19 @@ publishing {
9896 }
9997 }
10098 }
99+ repositories {
100+ maven {
101+ name = " staging"
102+ url = rootProject. layout. buildDirectory. dir(" staging-deploy${ File.separator} maven" )
103+ }
104+ maven {
105+ name = ' snapshots'
106+ url = " https://oss.sonatype.org/content/repositories/snapshots/"
107+ // So that Gradle uses the `ORG_GRADLE_PROJECT_snapshotsPassword` / `ORG_GRADLE_PROJECT_snapshotsUsername`
108+ // env variables to read the username/password for the `snapshots` repository publishing:
109+ credentials(PasswordCredentials )
110+ }
111+ }
101112}
102113
103114tasks. withType(PublishToMavenLocal ). configureEach {
@@ -122,81 +133,20 @@ tasks.withType(PublishToMavenRepository).configureEach {
122133 }
123134}
124135
125-
126- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
127- // Signing
128-
129- def signingKey = resolveSigningKey()
130- def signingPassphrase = resolveSigningPassphrase()
131-
132- var signingExtension = project. getExtensions(). getByType(SigningExtension ) as SigningExtension
133- signingExtension. sign publishing. publications. publishedArtifacts
134- signingExtension. useInMemoryPgpKeys(signingKey, signingPassphrase)
135-
136-
137- gradle. taskGraph. whenReady { TaskExecutionGraph graph ->
138- // are we publishing to OSSRH?
139- boolean wasPublishingRequested = false
140-
141- graph. allTasks. each {task ->
142- if ( task instanceof PublishToMavenRepository ) {
143- if ( " sonatype" == task. repository. name ) {
144- wasPublishingRequested = true
145- }
146- }
147- }
148-
149- if ( wasPublishingRequested ) {
150- def ossrhUser = System . getenv(). get( " ORG_GRADLE_PROJECT_sonatypeUsername" )
151- def ossrhPass = System . getenv(). get( " ORG_GRADLE_PROJECT_sonatypePassword" )
152- if ( ossrhUser == null || ossrhPass == null ) {
153- throw new RuntimeException ( " Cannot perform publishing to OSSRH without credentials." )
154- }
155- logger. lifecycle " Publishing {} : {} : {}" , project. group, project. name, project. version
156- signingExtension. required = true
157- }
158- else if ( signingKey == null || signingPassphrase == null ) {
159- tasks. withType( Sign ). each { t -> t. enabled = false }
160- }
161- }
162-
163- static String resolveSigningKey () {
164- var key = System . getenv(). get( " SIGNING_GPG_PRIVATE_KEY" )
165- if ( key != null ) {
166- return key
167- }
168-
169- var keyFile = System . getenv(). get( " SIGNING_GPG_PRIVATE_KEY_PATH" )
170- if ( keyFile != null ) {
171- return new File ( keyFile ). text
172- }
173-
174- return null
175- }
176-
177- static String resolveSigningPassphrase () {
178- return System . getenv(). get( " SIGNING_GPG_PASSPHRASE" )
179- }
180-
181-
182136// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
183137// Release / publishing tasks
184138
185139tasks. register(' ciBuild' ) {
186- dependsOn test, tasks . publishToSonatype
140+ dependsOn test
187141}
188142
189- tasks. release. dependsOn tasks. test, tasks . publishToSonatype
143+ tasks. release. dependsOn tasks. test
190144
191145tasks. preVerifyRelease. dependsOn build
192146tasks. preVerifyRelease. dependsOn generateMetadataFileForPublishedArtifactsPublication
193147tasks. preVerifyRelease. dependsOn generatePomFileForPublishedArtifactsPublication
194148tasks. preVerifyRelease. dependsOn generatePomFileForRelocationPomPublication
195149
196- tasks. publishToSonatype. mustRunAfter test
197-
198-
199-
200150// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
201151// Ancillary tasks
202152
0 commit comments