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