Ship milestones to Maven Central.

Closes #103
This commit is contained in:
Mark Paluch
2025-01-21 09:00:57 +01:00
parent bcdf865d83
commit 2b5ec1c08c
8 changed files with 16 additions and 32 deletions

View File

@@ -340,16 +340,12 @@ class MavenBuildSystem implements BuildSystem {
Assert.notNull(module, "Module iteration must not be null!");
Assert.notNull(information, "Deployment information must not be null!");
boolean isCommercialRelease = module.isCommercial();
if (!module.getIteration().isPreview() && !isCommercialRelease) {
logger.log(module,
"Not a preview version (milestone or release candidate) or commercial release. Skipping Artifactory deployment.");
if (!module.isCommercial()) {
logger.log(module, "Not a commercial release. Skipping Artifactory deployment.");
return;
}
logger.log(module,
String.format("Deploying artifacts to Spring %sArtifactory…", isCommercialRelease ? "Commercial " : ""));
logger.log(module, "Deploying artifacts to Spring Commercial Artifactory…");
Authentication authentication = properties.getAuthentication(module);
@@ -386,8 +382,8 @@ class MavenBuildSystem implements BuildSystem {
Assert.notNull(module, "Module iteration must not be null!");
Assert.notNull(deploymentInformation, "DeploymentInformation iteration must not be null!");
if (!module.isPublic()) {
logger.log(module, "Skipping deployment to Maven Central as it's not a public version or a commercial release!");
if (module.isCommercial()) {
logger.log(module, "Skipping deployment to Maven Central as it's a commercial release!");
return;
}
@@ -508,8 +504,7 @@ class MavenBuildSystem implements BuildSystem {
arg("artifactory.server").withValue(authentication.getServer().getUri()),
arg("artifactory.distribution-repository").withValue(authentication.getDistributionRepository()),
arg("artifactory.username").withValue(authentication.getUsername()),
arg("artifactory.password").withValue(authentication.getApiKey()))
.andIf(deploymentInformation != null, () -> {
arg("artifactory.password").withValue(authentication.getApiKey())).andIf(deploymentInformation != null, () -> {
return arg("artifactory.build-number").withValue(deploymentInformation.getBuildNumber());
}).andIf(!ObjectUtils.isEmpty(properties.getSettingsXml()), () -> settingsXml(properties.getSettingsXml())));
@@ -518,8 +513,7 @@ class MavenBuildSystem implements BuildSystem {
arg("artifactory.server").withValue(authentication.getServer().getUri()),
arg("artifactory.distribution-repository").withValue(authentication.getDistributionRepository()),
arg("artifactory.username").withValue(authentication.getUsername()),
arg("artifactory.password").withValue(authentication.getApiKey()))
.andIf(deploymentInformation != null, () -> {
arg("artifactory.password").withValue(authentication.getApiKey())).andIf(deploymentInformation != null, () -> {
return arg("artifactory.build-number").withValue(deploymentInformation.getBuildNumber());
}).andIf(!ObjectUtils.isEmpty(properties.getSettingsXml()), () -> settingsXml(properties.getSettingsXml())));

View File

@@ -26,7 +26,6 @@ import java.util.Collections;
import java.util.List;
import org.springframework.data.release.model.ArtifactVersion;
import org.springframework.data.release.model.Iteration;
import org.springframework.data.release.model.Phase;
import org.springframework.data.release.model.Project;
import org.springframework.data.release.model.SupportedProject;
@@ -91,15 +90,6 @@ public class UpdateInformation {
public List<Repository> getRepositories() {
if (phase == Phase.PREPARE) {
Iteration iteration = train.getIteration();
if (iteration.isMilestone() || iteration.isReleaseCandidate()) {
return Collections.singletonList(Repository.MILESTONE);
}
}
if (phase == Phase.CLEANUP || phase == Phase.MAINTENANCE) {
return train.isCommercial() ? Arrays.asList(Repository.COMMERCIAL_SNAPSHOT, Repository.COMMERCIAL_RELEASE)

View File

@@ -156,7 +156,6 @@ public class DefaultDeploymentInformation implements DeploymentInformation {
*/
@Override
public boolean isMavenCentral() {
return !module.isCommercial() && module.getIteration().isPublic();
}
}

View File

@@ -166,7 +166,8 @@ public class GitOperations {
}
private Branch getBranch(Train train, Module module, SupportedProject project) {
private Branch getBranch(Train train, org.springframework.data.release.model.Module module,
SupportedProject project) {
ModuleIteration gaIteration = train.getModuleIteration(project.getProject(), Iteration.GA);
Optional<Tag> gaTag = findTagFor(project, ArtifactVersion.of(gaIteration));

View File

@@ -64,7 +64,7 @@ interface DependencyUpgradePolicy {
@Override
public boolean restrictToMinorVersion() {
return iteration.isPublic();
return iteration.isGAIteration() || iteration.isServiceIteration();
}
};

View File

@@ -122,7 +122,7 @@ public class Iteration implements Comparable<Iteration> {
* @return
*/
public boolean isPublic() {
return isServiceIteration() || this.equals(GA);
return isMilestone() || isServiceIteration() || this.equals(GA);
}
/**
@@ -131,7 +131,7 @@ public class Iteration implements Comparable<Iteration> {
* @return
*/
public boolean isPreview() {
return !isPublic();
return isMilestone() || isReleaseCandidate();
}
public boolean isServiceIteration() {

View File

@@ -56,11 +56,11 @@ class UpdateInformationUnitTests {
}
@Test
void milestoneReposContainedForMilestoneRelease() {
void noReposContainedForMilestoneRelease() {
UpdateInformation updateInformation = UpdateInformation.of(hopperM1, Phase.PREPARE);
assertThat(updateInformation.getRepositories()).containsOnly(Repository.MILESTONE);
assertThat(updateInformation.getRepositories().isEmpty());
}
@Test

View File

@@ -58,10 +58,10 @@ class DeploymentInformationIntegrationTests extends AbstractIntegrationTests {
DeploymentInformation ossGA = new DefaultDeploymentInformation(
ReleaseTrains.VAUGHAN.getIteration(Iteration.GA).getModule(Projects.BUILD), properties);
assertThat(ossGA.getBuildNumber()).startsWith("spring-data-build-main-release");
assertThat(ossGA.getBuildNumber()).startsWith("spring-data-build-commercial-3.2.x-release");
DeploymentInformation ossSr1 = new DefaultDeploymentInformation(
ReleaseTrains.VAUGHAN.getIteration(Iteration.SR1).getModule(Projects.BUILD), properties);
assertThat(ossSr1.getBuildNumber()).startsWith("spring-data-build-3.2.x-release");
assertThat(ossSr1.getBuildNumber()).startsWith("spring-data-build-commercial-3.2.x");
}
}