|
|
|
|
@ -88,27 +88,6 @@ public class SonatypeService {
@@ -88,27 +88,6 @@ public class SonatypeService {
|
|
|
|
|
this.artifactCollector = new ArtifactCollector(sonatypeProperties.getExclude()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Checks if artifacts are already published to Maven Central. |
|
|
|
|
* @return true if artifacts are published |
|
|
|
|
* @param releaseInfo the release information |
|
|
|
|
*/ |
|
|
|
|
public boolean artifactsPublished(ReleaseInfo releaseInfo) { |
|
|
|
|
try { |
|
|
|
|
ResponseEntity<?> entity = this.restTemplate |
|
|
|
|
.getForEntity(String.format(NEXUS_REPOSITORY_PATH + "%s/spring-boot-%s.jar.sha1", |
|
|
|
|
releaseInfo.getVersion(), releaseInfo.getVersion()), byte[].class); |
|
|
|
|
if (HttpStatus.OK.equals(entity.getStatusCode())) { |
|
|
|
|
logger.info("Already published to Sonatype."); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
catch (HttpClientErrorException ex) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Publishes the release by creating a staging repository and deploying to it the |
|
|
|
|
* artifacts at the given {@code artifactsRoot}. The repository is then closed and, |
|
|
|
|
@ -117,6 +96,9 @@ public class SonatypeService {
@@ -117,6 +96,9 @@ public class SonatypeService {
|
|
|
|
|
* @param artifactsRoot the root directory of the artifacts to stage |
|
|
|
|
*/ |
|
|
|
|
public void publish(ReleaseInfo releaseInfo, Path artifactsRoot) { |
|
|
|
|
if (artifactsPublished(releaseInfo)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
logger.info("Creating staging repository"); |
|
|
|
|
String buildId = releaseInfo.getBuildNumber(); |
|
|
|
|
String repositoryId = createStagingRepository(buildId); |
|
|
|
|
@ -130,6 +112,22 @@ public class SonatypeService {
@@ -130,6 +112,22 @@ public class SonatypeService {
|
|
|
|
|
logger.info("Staging repository released"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean artifactsPublished(ReleaseInfo releaseInfo) { |
|
|
|
|
try { |
|
|
|
|
ResponseEntity<?> entity = this.restTemplate |
|
|
|
|
.getForEntity(String.format(NEXUS_REPOSITORY_PATH + "%s/spring-boot-%s.jar.sha1", |
|
|
|
|
releaseInfo.getVersion(), releaseInfo.getVersion()), byte[].class); |
|
|
|
|
if (HttpStatus.OK.equals(entity.getStatusCode())) { |
|
|
|
|
logger.info("Already published to Sonatype."); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
catch (HttpClientErrorException ex) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String createStagingRepository(String buildId) { |
|
|
|
|
Map<String, Object> body = new HashMap<>(); |
|
|
|
|
body.put("data", Collections.singletonMap("description", buildId)); |
|
|
|
|
|