Skip to content
This repository was archived by the owner on Dec 9, 2025. It is now read-only.

Commit f52b44e

Browse files
wilkinsonabclozel
authored andcommitted
Stop using Bintray to publish to Maven Central
This commit reworks the CI pipeline to remove the use of Bintray for publishing to Maven Central. In its place it adds a new publishToCentral command to the release scripts. This command can be used to publish a directory tree of artifacts to the Maven Central gateway hosted by Sonatype. Publishing consists of 4 steps: 1. Create the staging repository 2. Deploy artifacts to the repository 3. Close the repository 4. Release the repository The command requires 3 arguments: 1. The type of release being performed 2. Location of a build info JSON file that describes the release that is to be deployed 3. Root of a directory structure, in Maven repository layout, that contains the artifacts to be deployed Closes gh-7 See spring-projects/spring-boot#25107
1 parent 0282168 commit f52b44e

File tree

181 files changed

+2308
-1551
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+2308
-1551
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ dependencies {
2828
implementation 'org.springframework.boot:spring-boot-starter-json'
2929
implementation 'org.springframework:spring-web'
3030
implementation 'org.awaitility:awaitility'
31+
implementation 'org.bouncycastle:bcpg-jdk15to18:1.68'
3132
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
3233
testImplementation('org.springframework.boot:spring-boot-starter-test') {
3334
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'

src/main/java/io/spring/concourse/releasescripts/artifactory/ArtifactoryService.java

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,14 +17,10 @@
1717
package io.spring.concourse.releasescripts.artifactory;
1818

1919
import java.net.URI;
20-
import java.time.Duration;
21-
import java.util.Set;
2220

2321
import io.spring.concourse.releasescripts.ReleaseInfo;
2422
import io.spring.concourse.releasescripts.artifactory.payload.BuildInfoResponse;
25-
import io.spring.concourse.releasescripts.artifactory.payload.DistributionRequest;
2623
import io.spring.concourse.releasescripts.artifactory.payload.PromotionRequest;
27-
import io.spring.concourse.releasescripts.bintray.BintrayService;
2824
import org.slf4j.Logger;
2925
import org.slf4j.LoggerFactory;
3026

@@ -53,17 +49,11 @@ public class ArtifactoryService {
5349

5450
private static final String BUILD_INFO_URL = ARTIFACTORY_URL + "/api/build/";
5551

56-
private static final String DISTRIBUTION_URL = ARTIFACTORY_URL + "/api/build/distribute/";
57-
5852
private static final String STAGING_REPO = "libs-staging-local";
5953

6054
private final RestTemplate restTemplate;
6155

62-
private final BintrayService bintrayService;
63-
64-
public ArtifactoryService(RestTemplateBuilder builder, ArtifactoryProperties artifactoryProperties,
65-
BintrayService bintrayService) {
66-
this.bintrayService = bintrayService;
56+
public ArtifactoryService(RestTemplateBuilder builder, ArtifactoryProperties artifactoryProperties) {
6757
String username = artifactoryProperties.getUsername();
6858
String password = artifactoryProperties.getPassword();
6959
if (StringUtils.hasLength(username)) {
@@ -107,7 +97,7 @@ private boolean isAlreadyPromoted(String buildName, String buildNumber, String t
10797
ResponseEntity<BuildInfoResponse> entity = this.restTemplate
10898
.getForEntity(BUILD_INFO_URL + buildName + "/" + buildNumber, BuildInfoResponse.class);
10999
BuildInfoResponse.Status status = entity.getBody().getBuildInfo().getStatuses()[0];
110-
logger.debug("Reutned repository " + status.getRepository() + " expecting " + targetRepo);
100+
logger.debug("Returned repository " + status.getRepository() + " expecting " + targetRepo);
111101
return status.getRepository().equals(targetRepo);
112102
}
113103
catch (HttpClientErrorException ex) {
@@ -116,37 +106,6 @@ private boolean isAlreadyPromoted(String buildName, String buildNumber, String t
116106
}
117107
}
118108

119-
/**
120-
* Deploy builds from Artifactory to Bintray.
121-
* @param sourceRepo the source repo in Artifactory.
122-
* @param releaseInfo the resease info
123-
* @param artifactDigests the artifact digests
124-
*/
125-
public void distribute(String sourceRepo, ReleaseInfo releaseInfo, Set<String> artifactDigests) {
126-
logger.debug("Attempting distribute via Artifactory");
127-
if (!this.bintrayService.isDistributionStarted(releaseInfo)) {
128-
startDistribute(sourceRepo, releaseInfo);
129-
}
130-
if (!this.bintrayService.isDistributionComplete(releaseInfo, artifactDigests, Duration.ofMinutes(60))) {
131-
throw new DistributionTimeoutException("Distribution timed out.");
132-
}
133-
}
134-
135-
private void startDistribute(String sourceRepo, ReleaseInfo releaseInfo) {
136-
DistributionRequest request = new DistributionRequest(new String[] { sourceRepo });
137-
RequestEntity<DistributionRequest> requestEntity = RequestEntity
138-
.post(URI.create(DISTRIBUTION_URL + releaseInfo.getBuildName() + "/" + releaseInfo.getBuildNumber()))
139-
.contentType(MediaType.APPLICATION_JSON).body(request);
140-
try {
141-
this.restTemplate.exchange(requestEntity, Object.class);
142-
logger.debug("Distribute call completed");
143-
}
144-
catch (HttpClientErrorException ex) {
145-
logger.info("Failed to distribute.");
146-
throw ex;
147-
}
148-
}
149-
150109
private PromotionRequest getPromotionRequest(String targetRepo) {
151110
return new PromotionRequest("staged", STAGING_REPO, targetRepo);
152111
}

src/main/java/io/spring/concourse/releasescripts/artifactory/payload/BuildInfoResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/main/java/io/spring/concourse/releasescripts/artifactory/payload/DistributionRequest.java

Lines changed: 0 additions & 48 deletions
This file was deleted.

src/main/java/io/spring/concourse/releasescripts/bintray/BintrayProperties.java

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)