Skip to content

Commit e3e5c80

Browse files
authored
Bump version and migrate from OSSRH (#42)
1 parent 6a4f501 commit e3e5c80

File tree

3 files changed

+54
-5
lines changed

3 files changed

+54
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ buildscript {
3333
}
3434
3535
dependencies {
36-
classpath 'com.jeppeman.mockposable:mockposable-gradle:0.13'
36+
classpath 'com.jeppeman.mockposable:mockposable-gradle:0.14'
3737
}
3838
}
3939

gradle/gradle-mvn-push.gradle

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import groovy.json.JsonSlurper
2+
13
apply plugin: 'maven-publish'
24
apply plugin: 'signing'
35

@@ -11,13 +13,13 @@ def isReleaseBuild() {
1113
def getReleaseRepositoryUrl() {
1214
return hasProperty('RELEASE_REPOSITORY_URL')
1315
? RELEASE_REPOSITORY_URL
14-
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
16+
: "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/"
1517
}
1618

1719
def getSnapshotRepositoryUrl() {
1820
return hasProperty('SNAPSHOT_REPOSITORY_URL')
1921
? SNAPSHOT_REPOSITORY_URL
20-
: "https://oss.sonatype.org/content/repositories/snapshots/"
22+
: "https://ossrh-staging-api.central.sonatype.com/content/repositories/snapshots/"
2123
}
2224

2325
def getRepositoryUsername() {
@@ -168,4 +170,51 @@ afterEvaluate {
168170
}
169171
}
170172
}
171-
}
173+
174+
tasks.register('moveFromOSSRHToCentralPublisherPortal') {
175+
doLast {
176+
def repoKey = get('search/repositories').repositories[0].key
177+
post("upload/repository/$repoKey")
178+
}
179+
}
180+
181+
tasks.withType(PublishToMavenRepository) {
182+
finalizedBy('moveFromOSSRHToCentralPublisherPortal')
183+
}
184+
}
185+
186+
def request(path, method, body = null) {
187+
def url = "https://ossrh-staging-api.central.sonatype.com/manual/$path"
188+
def con = new URI("https://ossrh-staging-api.central.sonatype.com/manual/$path").toURL().openConnection()
189+
def str = new String(Base64.encoder.encode("${getRepositoryUsername()}:${getRepositoryPassword()}".getBytes()))
190+
con.addRequestProperty('Authorization', "Bearer $str")
191+
con.setRequestMethod(method)
192+
if (method == "POST" || method == "PUT") {
193+
con.setDoOutput(true)
194+
}
195+
if (body != null) {
196+
con.outputStream.write(body.getBytes())
197+
}
198+
def responseCode = con.getResponseCode()
199+
if (responseCode >= 200 && responseCode <= 299) {
200+
def responseBody = con.inputStream.getText()
201+
if (responseBody != null && !responseBody.isEmpty()) {
202+
return new JsonSlurper().parseText(responseBody)
203+
}
204+
} else {
205+
def errorBody = con?.errorStream?.getText()
206+
if (errorBody != null && !errorBody.isEmpty()) {
207+
throw new RuntimeException("$method $url failed: code=$responseCode, body=$errorBody")
208+
} else {
209+
throw new RuntimeException("$method $url failed: code=$responseCode")
210+
}
211+
}
212+
}
213+
214+
def get(path) {
215+
return request(path, 'GET')
216+
}
217+
218+
def post(path, body = null) {
219+
return request(path, 'POST', body)
220+
}

mockposable/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION_NAME=0.14-SNAPSHOT
1+
VERSION_NAME=0.15-SNAPSHOT
22
GROUP=com.jeppeman.mockposable
33

44
POM_DESCRIPTION=A tool that enables stubbing and verification of @Composable-annotated functions

0 commit comments

Comments
 (0)