Skip to content

Commit ac9b896

Browse files
committed
migrate from (meanwhile shut down) OSSRH to Central Publisher Portal using the Portal OSSRH Staging API
cf. https://central.sonatype.org/news/20250326_ossrh_sunset/, https://central.sonatype.org/publish/publish-portal-ossrh-staging-api/ and https://central.sonatype.org/publish/publish-portal-api/#manually-testing-a-deployment-bundle As the snapshots repository is currently not used, its configuration is just a best guess at this point. Signed-off-by: Manfred Hanke <Manfred.Hanke@tngtech.com>
1 parent b72fcaf commit ac9b896

4 files changed

Lines changed: 25 additions & 13 deletions

File tree

archunit-maven-test/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ def repositoryUrls = [
1616
releases : 'https://nexus.int.tngtech.com/repository/maven-releases'
1717
],
1818
sonatype: [
19-
snapshots: 'https://oss.sonatype.org/content/repositories/snapshots',
20-
releases : 'https://oss.sonatype.org/content/repositories/releases'
19+
snapshots: 'https://central.sonatype.com/repository/maven-snapshots',
20+
releases : 'https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/'
2121
]
2222
]
2323
def createRepositoriesTag = { repoUrls ->

build-steps/release/publish.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ nexusPublishing {
77
packageGroup = 'com.tngtech'
88
repositories {
99
sonatype {
10+
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
11+
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
1012
username = findProperty("sonatypeUsername")
1113
password = findProperty("sonatypePassword")
1214
}

build-steps/release/test-release.gradle

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,22 @@ task testRelease() {
99
text = text.replace('mavenCentral()', '''
1010
mavenCentral()
1111
maven {
12-
url "https://oss.sonatype.org/content/repositories/staging/"
13-
credentials {
14-
username project.getProperty('sonatypeUsername')
15-
password project.getProperty('sonatypePassword')
12+
url "https://central.sonatype.com/api/v1/publisher/deployments/download/"
13+
credentials(HttpHeaderCredentials) {
14+
name = "Authorization"
15+
value = "Bearer " + (project.getProperty('sonatypeUsername') + ":" + project.getProperty('sonatypePassword')).bytes.encodeBase64()
16+
}
17+
authentication {
18+
header(HttpHeaderAuthentication)
1619
}
1720
}''')
1821
}
1922
}
2023

24+
def configureHttpSocketTimeout = {
25+
new File(testReleaseDir, 'gradle.properties') << 'systemProp.org.gradle.internal.http.socketTimeout=600000\n'
26+
}
27+
2128
def testExampleProject = { String exampleProjectName ->
2229
List<String> testClassNames = fileTree(new File(testReleaseDir, exampleProjectName)) {
2330
include '**/*Test.java'
@@ -47,6 +54,7 @@ task testRelease() {
4754
updateArchUnitExampleVersion(testReleaseDir)
4855

4956
configureStagingRepository()
57+
configureHttpSocketTimeout()
5058

5159
testExampleProject('example-plain')
5260
testExampleProject('example-junit4')

buildSrc/src/main/groovy/archunit.java-release-check-conventions.gradle

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,25 @@ ext.getExpectedPomFileContent = {
3838

3939
task checkUploadedArtifacts {
4040
doLast {
41-
def tngRepoId = project.findProperty('tngRepoId') ?: rootProject.closeSonatypeStagingRepository.stagingRepositoryId.get()
42-
def rootUrl = "https://oss.sonatype.org/service/local/repositories/${tngRepoId}/content/com/tngtech/archunit"
43-
44-
def createArtifactUrl = { String artifactId ->
45-
"${rootUrl}/${artifactId}/${version}/${artifactId}-${version}"
41+
def getArtifact = { String artifactId, String fullEnding ->
42+
def repositoryUrl = 'https://central.sonatype.com/api/v1/publisher/deployments/download'
43+
def artifactUrl = "$repositoryUrl/com/tngtech/archunit/$artifactId/$version/$artifactId-$version$fullEnding"
44+
def connection = new URL(artifactUrl).openConnection()
45+
def token = (project.getProperty('sonatypeUsername') + ':' + project.getProperty('sonatypePassword')).bytes.encodeBase64()
46+
connection.setRequestProperty("Authorization", "Bearer $token")
47+
return connection.inputStream
4648
}
4749

4850
def getUploadedFile = { String artifactId, String ending, String suffix ->
4951
def fullEnding = (!suffix.isEmpty() ? "-${suffix}" : '') + ".${ending}"
5052
def tempDir = Files.createTempDirectory('release-check').toFile()
5153
File result = new File(tempDir, "${artifactId}${fullEnding}")
52-
result.bytes = new URL("${createArtifactUrl(artifactId)}${fullEnding}").bytes
54+
result.bytes = getArtifact(artifactId, fullEnding).bytes
5355
result
5456
}
5557

5658
def getUploadedPomFileContent = {
57-
new URL("${createArtifactUrl(project.name)}.pom").text.stripIndent()
59+
getArtifact(project.name, ".pom").text.stripIndent()
5860
}
5961

6062
def checkPom = {

0 commit comments

Comments
 (0)