File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed
Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change 11publishing {
22 repositories {
33 maven {
4- name = " ossrh"
5- url = " https://s01.oss.sonatype.org/" + (project. maven_version. endsWith(" SNAPSHOT" ) ? " content/repositories/snapshots/" : " service/local/staging/deploy/maven2/" )
4+ name = " central"
5+ if (project. maven_version. endsWith(" SNAPSHOT" )) {
6+ url = " https://central.sonatype.com/repository/maven-snapshots"
7+ } else {
8+ url = " https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2"
9+ }
610
711 credentials(PasswordCredentials )
812 authentication {
@@ -11,3 +15,21 @@ publishing {
1115 }
1216 }
1317}
18+
19+ tasks. withType(PublishToMavenRepository ). configureEach {
20+ if (it. name. endsWith(" ToCentralRepository" )) {
21+ def centralUsername = providers. gradleProperty(" centralUsername" )
22+ def centralPassword = providers. gradleProperty(" centralPassword" )
23+ def mavenGroup = it. publication. groupId
24+ it. doLast {
25+ def connection = URI . create(" https://ossrh-staging-api.central.sonatype.com/manual/upload/defaultRepository/$mavenGroup " ). toURL(). openConnection() as HttpURLConnection
26+ connection. setRequestMethod(" POST" )
27+ connection. setRequestProperty(" Authorization" , " Basic " + " ${ centralUsername.get()} :${ centralPassword.get()} " . bytes. encodeBase64(). toString())
28+ connection. connect()
29+ if (connection. getResponseCode() != 200 ) {
30+ throw new GradleException (" Failed to close staging repository: ${ connection.getResponseCode()} ${ connection.getResponseMessage()} " )
31+ }
32+ connection. disconnect()
33+ }
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments