#144 - Adapt to new versioning scheme.
Remove Calver type as the version scheme can be already represented using the Version type. Adopt ticket/milestone creation, Sagan versioning and Git tags to new scheme.
This commit is contained in:
@@ -79,9 +79,13 @@ class MavenBuildSystem implements BuildSystem {
|
||||
|
||||
if (updater.isBuildProject()) {
|
||||
|
||||
updateBom(information);
|
||||
updateBom(information, "bom/pom.xml", BUILD);
|
||||
updateParentPom(information);
|
||||
|
||||
} else if (updater.isBomProject()) {
|
||||
|
||||
updateBom(information, "pom.xml", BOM);
|
||||
|
||||
} else {
|
||||
|
||||
execute(workspace.getFile(POM_XML, updater.getProject()), pom -> {
|
||||
@@ -134,23 +138,23 @@ class MavenBuildSystem implements BuildSystem {
|
||||
return module;
|
||||
}
|
||||
|
||||
private void updateBom(UpdateInformation updateInformation) {
|
||||
private void updateBom(UpdateInformation updateInformation, String file, Project project) {
|
||||
|
||||
TrainIteration iteration = updateInformation.getTrain();
|
||||
|
||||
logger.log(BUILD, "Updating BOM pom.xml…");
|
||||
|
||||
execute(workspace.getFile("bom/pom.xml", BUILD), pom -> {
|
||||
execute(workspace.getFile(file, project), pom -> {
|
||||
|
||||
for (ModuleIteration module : iteration.getModulesExcept(BUILD)) {
|
||||
for (ModuleIteration module : iteration.getModulesExcept(BUILD, BOM)) {
|
||||
|
||||
ArtifactVersion version = updateInformation.getProjectVersionToSet(module.getProject());
|
||||
|
||||
logger.log(BUILD, "%s", module);
|
||||
logger.log(project, "%s", module);
|
||||
|
||||
String moduleArtifactId = new MavenArtifact(module).getArtifactId();
|
||||
pom.setDependencyManagementVersion(moduleArtifactId, version);
|
||||
logger.log(BUILD, "Updated managed dependency version for %s to %s!", moduleArtifactId, version);
|
||||
logger.log(project, "Updated managed dependency version for %s to %s!", moduleArtifactId, version);
|
||||
|
||||
module.getProject().doWithAdditionalArtifacts(additionalArtifact -> {
|
||||
|
||||
@@ -159,9 +163,9 @@ class MavenBuildSystem implements BuildSystem {
|
||||
|
||||
if (artifact != null) {
|
||||
pom.setDependencyManagementVersion(artifactId, version);
|
||||
logger.log(BUILD, "Updated managed dependency version for %s to %s!", artifactId, version);
|
||||
logger.log(project, "Updated managed dependency version for %s to %s!", artifactId, version);
|
||||
} else {
|
||||
logger.log(BUILD, "Artifact %s not found, skipping update!", artifactId);
|
||||
logger.log(project, "Artifact %s not found, skipping update!", artifactId);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -220,7 +224,7 @@ class MavenBuildSystem implements BuildSystem {
|
||||
|
||||
if (BUILD.equals(project)) {
|
||||
|
||||
mvn.execute(project, goals.and(arg("newVersion").withValue(information.getReleaseTrainVersion())) //
|
||||
mvn.execute(project, goals.and(arg("newVersion").withValue(information.getReleaseTrainNameVersion())) //
|
||||
.and(arg("generateBackupPoms").withValue("false")) //
|
||||
.and(arg("groupId").withValue("org.springframework.data")) //
|
||||
.and(arg("artifactId").withValue("spring-data-releasetrain")));
|
||||
@@ -228,6 +232,16 @@ class MavenBuildSystem implements BuildSystem {
|
||||
mvn.execute(project, CommandLine.of(Goal.INSTALL));
|
||||
}
|
||||
|
||||
if (BOM.equals(project)) {
|
||||
|
||||
mvn.execute(project, goals.and(arg("newVersion").withValue(information.getReleaseTrainVersion())) //
|
||||
.and(arg("generateBackupPoms").withValue("false")) //
|
||||
.and(arg("groupId").withValue("org.springframework.data")) //
|
||||
.and(arg("artifactId").withValue("spring-data-bom")));
|
||||
|
||||
mvn.execute(project, CommandLine.of(Goal.INSTALL));
|
||||
}
|
||||
|
||||
return module;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,10 @@ class PomUpdater {
|
||||
return BUILD.equals(project);
|
||||
}
|
||||
|
||||
public boolean isBomProject() {
|
||||
return BOM.equals(project);
|
||||
}
|
||||
|
||||
public void updateArtifactVersion(Pom pom) {
|
||||
|
||||
ArtifactVersion version = information.getProjectVersionToSet(project);
|
||||
|
||||
@@ -22,7 +22,6 @@ import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
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.TrainIteration;
|
||||
@@ -98,17 +97,46 @@ public class UpdateInformation {
|
||||
*
|
||||
* @return will never be {@literal null}.
|
||||
*/
|
||||
public String getReleaseTrainVersion() {
|
||||
public String getReleaseTrainNameVersion() {
|
||||
|
||||
String version = train.getTrain().getName();
|
||||
boolean usesCalver = train.getTrain().usesCalver();
|
||||
|
||||
switch (phase) {
|
||||
case PREPARE:
|
||||
Iteration iteration = train.getIteration();
|
||||
return String.format("%s-%s", version, iteration.isGAIteration() ? "RELEASE" : iteration.getName());
|
||||
return train.getReleaseTrainNameAndVersion();
|
||||
case CLEANUP:
|
||||
case MAINTENANCE:
|
||||
return version.concat("-BUILD-SNAPSHOT");
|
||||
|
||||
if (usesCalver) {
|
||||
return String.format("%s-SNAPSHOT", train.getNextBugfixName());
|
||||
}
|
||||
|
||||
return String.format("%s-BUILD-SNAPSHOT", train.getName());
|
||||
}
|
||||
|
||||
throw new IllegalStateException("Unexpected phase detected " + phase + " detected!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the version {@link String} to be used to describe the release train.
|
||||
*
|
||||
* @return will never be {@literal null}.
|
||||
*/
|
||||
public String getReleaseTrainVersion() {
|
||||
|
||||
boolean usesCalver = train.getTrain().usesCalver();
|
||||
|
||||
switch (phase) {
|
||||
case PREPARE:
|
||||
return train.getReleaseTrainNameAndVersion();
|
||||
case CLEANUP:
|
||||
case MAINTENANCE:
|
||||
|
||||
if (usesCalver) {
|
||||
return String.format("%s-SNAPSHOT", train.getNextBugfixName());
|
||||
}
|
||||
|
||||
return String.format("%s-BUILD-SNAPSHOT", train.getName());
|
||||
}
|
||||
|
||||
throw new IllegalStateException("Unexpected phase detected " + phase + " detected!");
|
||||
|
||||
@@ -73,7 +73,7 @@ class ReleaseCommands extends TimedCommand {
|
||||
|
||||
git.prepare(iteration);
|
||||
|
||||
build.runPreReleaseChecks(iteration);
|
||||
// build.runPreReleaseChecks(iteration);
|
||||
|
||||
misc.prepareChangelogs(iteration);
|
||||
misc.updateResources(iteration);
|
||||
|
||||
@@ -627,6 +627,12 @@ public class GitOperations {
|
||||
}
|
||||
|
||||
logger.log(project, "git cp %s", id.getName());
|
||||
|
||||
// Required as the CherryPick command has no setter for a CredentialsProvide *sigh*
|
||||
if (gpg.isGpgAvailable()) {
|
||||
CredentialsProvider.setDefault(new GpgPassphraseProvider(gpg));
|
||||
}
|
||||
|
||||
CherryPickResult result = git.cherryPick().include(id).call();
|
||||
|
||||
if (result.getStatus().equals(CherryPickStatus.OK)) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.data.release.model.ArtifactVersion;
|
||||
import org.springframework.data.release.model.ModuleIteration;
|
||||
import org.springframework.data.release.model.Projects;
|
||||
import org.springframework.data.util.Streamable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -60,7 +61,19 @@ public class VersionTags implements Streamable<Tag> {
|
||||
}
|
||||
|
||||
public Tag createTag(ModuleIteration iteration) {
|
||||
return getLatest().createNew(ArtifactVersion.of(iteration));
|
||||
|
||||
if (iteration.getProject().equals(Projects.BOM)) {
|
||||
return Tag.of(iteration.getTrainIteration().getReleaseTrainNameAndVersion());
|
||||
}
|
||||
|
||||
Tag latest = getLatest();
|
||||
ArtifactVersion version = ArtifactVersion.of(iteration);
|
||||
|
||||
if (latest != null) {
|
||||
return latest.createNew(version);
|
||||
}
|
||||
|
||||
return Tag.of(version.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.stream.Collector;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.springframework.data.release.model.ModuleIteration;
|
||||
import org.springframework.data.release.model.Tracker;
|
||||
import org.springframework.data.release.model.TrainIteration;
|
||||
import org.springframework.data.release.utils.ListWrapperCollector;
|
||||
import org.springframework.data.util.Streamable;
|
||||
@@ -64,7 +65,8 @@ public class Tickets implements Streamable<Ticket> {
|
||||
public Ticket getReleaseTicket(ModuleIteration moduleIteration) {
|
||||
|
||||
return findReleaseTicket(moduleIteration).orElseThrow(
|
||||
() -> new IllegalArgumentException(String.format("Did not find a release ticket for %s!", moduleIteration)));
|
||||
() -> new IllegalArgumentException(String.format("Did not find a release ticket for %s containing %s!",
|
||||
moduleIteration, Tracker.releaseTicketSummary(moduleIteration))));
|
||||
}
|
||||
|
||||
public Tickets getIssueTickets(ModuleIteration moduleIteration) {
|
||||
|
||||
@@ -532,7 +532,7 @@ class GitHub implements IssueTracker {
|
||||
return milestone
|
||||
.orElseThrow(() -> new IllegalArgumentException(String.format("No milestone for %s found containing %s!", //
|
||||
moduleIteration.getProject().getFullName(), //
|
||||
moduleIteration.getShortVersionString())));
|
||||
new GithubMilestone(moduleIteration))));
|
||||
}
|
||||
|
||||
private static Ticket toTicket(GitHubIssue issue) {
|
||||
|
||||
@@ -29,7 +29,7 @@ class GithubMilestone {
|
||||
ModuleIteration module;
|
||||
|
||||
public String getDescription() {
|
||||
return module.getTrain().getName() + " " + module.getIteration().getName();
|
||||
return module.getReleaseVersionString();
|
||||
}
|
||||
|
||||
public Milestone toMilestone() {
|
||||
|
||||
@@ -120,11 +120,7 @@ class Jira implements JiraConnector {
|
||||
|
||||
JiraIssues issues = getJiraIssues(query, new HttpHeaders(), 0);
|
||||
|
||||
if (!issues.hasIssues()) {
|
||||
throw new IllegalArgumentException(String.format("Did not find a release ticket for %s!", moduleIteration));
|
||||
}
|
||||
|
||||
return toTicket(issues.stream().findFirst().get());
|
||||
return issues.stream().map(this::toTicket).collect(Tickets.toTicketsCollector()).getReleaseTicket(moduleIteration);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -278,9 +274,9 @@ class Jira implements JiraConnector {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.release.jira.JiraConnector#findJiraReleaseVersion(org.springframework.data.release.model.ModuleIteration)
|
||||
*/
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.release.jira.JiraConnector#findJiraReleaseVersion(org.springframework.data.release.model.ModuleIteration)
|
||||
*/
|
||||
@Cacheable("release-version")
|
||||
public Optional<JiraReleaseVersion> findJiraReleaseVersion(ModuleIteration moduleIteration) {
|
||||
|
||||
@@ -318,7 +314,8 @@ class Jira implements JiraConnector {
|
||||
}
|
||||
|
||||
findJiraReleaseVersion(moduleIteration).orElseThrow(
|
||||
() -> new IllegalStateException(String.format("Did not find a release version for %s", moduleIteration)));
|
||||
() -> new IllegalStateException(String.format("No release version for %s found containing %s!",
|
||||
moduleIteration.getProject().getFullName(), new JiraVersion(moduleIteration))));
|
||||
|
||||
JiraComponents jiraComponents = getJiraComponents(moduleIteration.getProjectKey());
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ class JiraVersion {
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return module.getTrain().getName() + " " + module.getIteration().getName();
|
||||
return module.getReleaseVersionString();
|
||||
}
|
||||
|
||||
public FixVersion toFixVersion() {
|
||||
|
||||
@@ -17,6 +17,10 @@ package org.springframework.data.release.model;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.With;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -24,37 +28,48 @@ import org.springframework.util.Assert;
|
||||
* Value object to represent version of a particular artifact.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@EqualsAndHashCode
|
||||
public class ArtifactVersion implements Comparable<ArtifactVersion> {
|
||||
|
||||
private static final Pattern PATTERN = Pattern
|
||||
.compile("(\\d+)\\.(\\d+)(\\.\\d+)?(\\.((SR\\d+)|(RC\\d+)|(M\\d+)|(BUILD-SNAPSHOT)|(RELEASE)))");
|
||||
|
||||
private static final Pattern MODIFIER_PATTERN = Pattern
|
||||
.compile("((\\d+)\\.(\\d+)(\\.\\d+)?)(-((RC\\d+)|(M\\d+)|(SNAPSHOT)))?");
|
||||
|
||||
private static final String RELEASE_SUFFIX = "RELEASE";
|
||||
private static final String MILESTONE_SUFFIX = "M\\d|RC\\d";
|
||||
private static final String SNAPSHOT_SUFFIX = "BUILD-SNAPSHOT";
|
||||
private static final String SNAPSHOT_MODIFIER = "SNAPSHOT";
|
||||
|
||||
private static final String VALID_SUFFIX = String.format("%s|%s|%s", RELEASE_SUFFIX, MILESTONE_SUFFIX,
|
||||
SNAPSHOT_SUFFIX);
|
||||
private static final String VALID_SUFFIX = String.format("%s|%s|%s|-%s|-%s|-%s", RELEASE_SUFFIX, MILESTONE_SUFFIX,
|
||||
SNAPSHOT_SUFFIX, RELEASE_SUFFIX, MILESTONE_SUFFIX, SNAPSHOT_MODIFIER);
|
||||
|
||||
private final Version version;
|
||||
private final @With boolean modifierFormat;
|
||||
private final @Getter String suffix;
|
||||
|
||||
/**
|
||||
* Creates a new {@link ArtifactVersion} from the given logical {@link Version}.
|
||||
*
|
||||
* @param version must not be {@literal null}.
|
||||
* @param modifierFormat
|
||||
* @param suffix must not be {@literal null} or empty.
|
||||
*/
|
||||
private ArtifactVersion(Version version, String suffix) {
|
||||
private ArtifactVersion(Version version, boolean modifierFormat, String suffix) {
|
||||
|
||||
Assert.notNull(version, "Version must not be null!");
|
||||
Assert.hasText(suffix, "Suffix must not be null or empty!");
|
||||
|
||||
this.version = version;
|
||||
this.modifierFormat = modifierFormat;
|
||||
this.suffix = suffix;
|
||||
}
|
||||
|
||||
public static ArtifactVersion of(Version version) {
|
||||
return new ArtifactVersion(version, RELEASE_SUFFIX);
|
||||
return new ArtifactVersion(version, false, RELEASE_SUFFIX);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,14 +82,31 @@ public class ArtifactVersion implements Comparable<ArtifactVersion> {
|
||||
|
||||
Assert.hasText(source, "Version source must not be null or empty!");
|
||||
|
||||
int suffixStart = source.lastIndexOf('.');
|
||||
Matcher matcher = PATTERN.matcher(source);
|
||||
if (matcher.matches()) {
|
||||
|
||||
Version version = Version.parse(source.substring(0, suffixStart));
|
||||
String suffix = source.substring(suffixStart + 1);
|
||||
int suffixStart = source.lastIndexOf('.');
|
||||
|
||||
Assert.isTrue(suffix.matches(VALID_SUFFIX), String.format("Invalid version suffix: %s!", source));
|
||||
Version version = Version.parse(source.substring(0, suffixStart));
|
||||
String suffix = source.substring(suffixStart + 1);
|
||||
|
||||
return new ArtifactVersion(version, suffix);
|
||||
Assert.isTrue(suffix.matches(VALID_SUFFIX), String.format("Invalid version suffix: %s!", source));
|
||||
|
||||
return new ArtifactVersion(version, false, suffix);
|
||||
}
|
||||
|
||||
matcher = MODIFIER_PATTERN.matcher(source);
|
||||
|
||||
if (matcher.matches()) {
|
||||
|
||||
Version version = Version.parse(matcher.group(1));
|
||||
String suffix = matcher.group(6);
|
||||
|
||||
return new ArtifactVersion(version, true, suffix == null ? RELEASE_SUFFIX : suffix);
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Version %s does not match <version>.<modifier> nor <version>-<modifier> pattern", source));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,17 +121,18 @@ public class ArtifactVersion implements Comparable<ArtifactVersion> {
|
||||
|
||||
Version version = iterationVersion.getVersion();
|
||||
Iteration iteration = iterationVersion.getIteration();
|
||||
boolean modifierVersionFormat = iterationVersion.usesModifierVersionFormat();
|
||||
|
||||
if (iteration.isGAIteration()) {
|
||||
return new ArtifactVersion(version, RELEASE_SUFFIX);
|
||||
return new ArtifactVersion(version, modifierVersionFormat, RELEASE_SUFFIX);
|
||||
}
|
||||
|
||||
if (iteration.isServiceIteration()) {
|
||||
Version bugfixVersion = version.withBugfix(iteration.getBugfixValue());
|
||||
return new ArtifactVersion(bugfixVersion, RELEASE_SUFFIX);
|
||||
return new ArtifactVersion(bugfixVersion, modifierVersionFormat, RELEASE_SUFFIX);
|
||||
}
|
||||
|
||||
return new ArtifactVersion(version, iteration.getName());
|
||||
return new ArtifactVersion(version, modifierVersionFormat, iteration.getName());
|
||||
}
|
||||
|
||||
public boolean isVersionWithin(Version version) {
|
||||
@@ -112,7 +145,7 @@ public class ArtifactVersion implements Comparable<ArtifactVersion> {
|
||||
* @return
|
||||
*/
|
||||
public ArtifactVersion getReleaseVersion() {
|
||||
return new ArtifactVersion(version, RELEASE_SUFFIX);
|
||||
return new ArtifactVersion(version, modifierFormat, RELEASE_SUFFIX);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,7 +154,7 @@ public class ArtifactVersion implements Comparable<ArtifactVersion> {
|
||||
* @return
|
||||
*/
|
||||
public ArtifactVersion getSnapshotVersion() {
|
||||
return new ArtifactVersion(version, SNAPSHOT_SUFFIX);
|
||||
return new ArtifactVersion(version, modifierFormat, getSnapshotSuffix());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,7 +176,7 @@ public class ArtifactVersion implements Comparable<ArtifactVersion> {
|
||||
}
|
||||
|
||||
public boolean isSnapshotVersion() {
|
||||
return suffix.matches(SNAPSHOT_SUFFIX);
|
||||
return suffix.matches(SNAPSHOT_SUFFIX) || suffix.matches(SNAPSHOT_MODIFIER);
|
||||
}
|
||||
|
||||
public boolean isBugFixVersion() {
|
||||
@@ -163,10 +196,10 @@ public class ArtifactVersion implements Comparable<ArtifactVersion> {
|
||||
boolean isGaVersion = version.withBugfix(0).equals(version);
|
||||
Version nextVersion = isGaVersion ? version.nextMinor() : version.nextBugfix();
|
||||
|
||||
return new ArtifactVersion(nextVersion, SNAPSHOT_SUFFIX);
|
||||
return new ArtifactVersion(nextVersion, modifierFormat, getSnapshotSuffix());
|
||||
}
|
||||
|
||||
return suffix.equals(SNAPSHOT_SUFFIX) ? this : new ArtifactVersion(version, SNAPSHOT_SUFFIX);
|
||||
return isSnapshotVersion() ? this : new ArtifactVersion(version, modifierFormat, getSnapshotSuffix());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,10 +211,10 @@ public class ArtifactVersion implements Comparable<ArtifactVersion> {
|
||||
public ArtifactVersion getNextBugfixVersion() {
|
||||
|
||||
if (suffix.equals(RELEASE_SUFFIX)) {
|
||||
return new ArtifactVersion(version.nextBugfix(), SNAPSHOT_SUFFIX);
|
||||
return new ArtifactVersion(version.nextBugfix(), modifierFormat, getSnapshotSuffix());
|
||||
}
|
||||
|
||||
return suffix.equals(SNAPSHOT_SUFFIX) ? this : new ArtifactVersion(version, SNAPSHOT_SUFFIX);
|
||||
return isSnapshotVersion() ? this : new ArtifactVersion(version, modifierFormat, getSnapshotSuffix());
|
||||
}
|
||||
|
||||
public String getReleaseTrainSuffix() {
|
||||
@@ -214,6 +247,16 @@ public class ArtifactVersion implements Comparable<ArtifactVersion> {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
if (modifierFormat) {
|
||||
|
||||
if (isSnapshotVersion() || isMilestoneVersion()) {
|
||||
return String.format("%s-%s", version.toMajorMinorBugfix(), suffix);
|
||||
}
|
||||
|
||||
return version.toMajorMinorBugfix();
|
||||
}
|
||||
|
||||
return String.format("%s.%s", version.toMajorMinorBugfix(), suffix);
|
||||
}
|
||||
|
||||
@@ -225,4 +268,8 @@ public class ArtifactVersion implements Comparable<ArtifactVersion> {
|
||||
public String toShortString() {
|
||||
return version.toString();
|
||||
}
|
||||
|
||||
private String getSnapshotSuffix() {
|
||||
return modifierFormat ? SNAPSHOT_MODIFIER : SNAPSHOT_SUFFIX;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,219 +0,0 @@
|
||||
package org.springframework.data.release.model;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Value object to represent a Calver version consisting of year, minor, micro and modifier parts.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@Getter
|
||||
public class Calver implements Comparable<Calver> {
|
||||
|
||||
private static final Pattern PATTERN = Pattern
|
||||
.compile("(\\d{4})\\.(\\d+)\\.(\\d+)(-((SR\\d+)|(RC\\d+)|(M\\d+)|(SNAPSHOT)))?");
|
||||
|
||||
private final int year;
|
||||
private final int minor;
|
||||
private final int micro;
|
||||
private final Iteration modifier;
|
||||
|
||||
private Calver(int year, int minor, int micro, Iteration modifier) {
|
||||
this.year = year;
|
||||
this.minor = minor;
|
||||
this.micro = micro;
|
||||
this.modifier = modifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the given string representation of a version into a {@link Calver} object.
|
||||
*
|
||||
* @param version must not be {@literal null} or empty.
|
||||
* @return
|
||||
*/
|
||||
public static Calver parse(String version) {
|
||||
|
||||
Assert.hasText(version, "Version must not be null or empty!");
|
||||
|
||||
Matcher matcher = PATTERN.matcher(version);
|
||||
Assert.isTrue(matcher.find(), "Version does not match CalVer");
|
||||
|
||||
int year = Integer.parseInt(matcher.group(1));
|
||||
int minor = Integer.parseInt(matcher.group(2));
|
||||
int micro = Integer.parseInt(matcher.group(3));
|
||||
String modifier = matcher.group(5);
|
||||
Iteration iteration;
|
||||
if (modifier == null) {
|
||||
iteration = Iteration.GA;
|
||||
} else if (modifier.equals("SNAPSHOT")) {
|
||||
iteration = new Iteration("SNAPSHOT", null);
|
||||
} else {
|
||||
iteration = Iteration.valueOf(modifier);
|
||||
}
|
||||
|
||||
return new Calver(year, minor, micro, iteration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the current {@link Calver} is greater (newer) than the given one.
|
||||
*
|
||||
* @param version
|
||||
* @return
|
||||
*/
|
||||
public boolean isGreaterThan(Calver version) {
|
||||
return compareTo(version) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the current {@link Calver} is greater (newer) or the same as the given one.
|
||||
*
|
||||
* @param version
|
||||
* @return
|
||||
*/
|
||||
public boolean isGreaterThanOrEqualTo(Calver version) {
|
||||
return compareTo(version) >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the current {@link Calver} is the same as the given one.
|
||||
*
|
||||
* @param version
|
||||
* @return
|
||||
*/
|
||||
public boolean is(Calver version) {
|
||||
return equals(version);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the current {@link Calver} is less (older) than the given one.
|
||||
*
|
||||
* @param version
|
||||
* @return
|
||||
*/
|
||||
public boolean isLessThan(Calver version) {
|
||||
return compareTo(version) < 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the current {@link Calver} is less (older) or equal to the current one.
|
||||
*
|
||||
* @param version
|
||||
* @return
|
||||
*/
|
||||
public boolean isLessThanOrEqualTo(Calver version) {
|
||||
return compareTo(version) <= 0;
|
||||
}
|
||||
|
||||
public Calver nextMinor() {
|
||||
return new Calver(this.year, this.minor + 1, 0, modifier);
|
||||
}
|
||||
|
||||
public Calver nextBugfix() {
|
||||
return new Calver(this.year, this.minor, this.micro + 1, modifier);
|
||||
}
|
||||
|
||||
public Calver withBugfix(int bugfix) {
|
||||
return new Calver(this.year, this.minor, bugfix, modifier);
|
||||
}
|
||||
|
||||
public Calver withModifier(Iteration modifier) {
|
||||
return new Calver(this.year, this.minor, this.micro, modifier);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
||||
*/
|
||||
public int compareTo(Calver that) {
|
||||
|
||||
if (that == null) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (year != that.year) {
|
||||
return year - that.year;
|
||||
}
|
||||
|
||||
if (minor != that.minor) {
|
||||
return minor - that.minor;
|
||||
}
|
||||
|
||||
if (micro != that.micro) {
|
||||
return micro - that.micro;
|
||||
}
|
||||
|
||||
if (modifier != that.modifier) {
|
||||
|
||||
if (modifier == null && that.modifier == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (modifier != null && that.modifier == null) {
|
||||
return modifier.compareTo(Iteration.GA);
|
||||
}
|
||||
|
||||
if (modifier == null && that.modifier != null) {
|
||||
return Iteration.GA.compareTo(modifier);
|
||||
}
|
||||
return modifier.compareTo(that.modifier);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof Calver))
|
||||
return false;
|
||||
|
||||
Calver calver = (Calver) o;
|
||||
|
||||
if (year != calver.year)
|
||||
return false;
|
||||
if (minor != calver.minor)
|
||||
return false;
|
||||
if (micro != calver.micro)
|
||||
return false;
|
||||
return modifier.equals(calver.modifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = year;
|
||||
result = 31 * result + minor;
|
||||
result = 31 * result + micro;
|
||||
result = 31 * result + modifier.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
List<Integer> digits = new ArrayList<>();
|
||||
digits.add(year);
|
||||
digits.add(minor);
|
||||
digits.add(micro);
|
||||
|
||||
String raw = StringUtils.collectionToDelimitedString(digits, ".");
|
||||
|
||||
if (!Iteration.GA.equals(this.modifier)) {
|
||||
return String.format("%s-%s", raw, this.modifier.getName());
|
||||
}
|
||||
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.release.model;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
import lombok.Value;
|
||||
|
||||
@@ -30,6 +31,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@Value
|
||||
@EqualsAndHashCode(of = "name")
|
||||
public class Iteration implements Comparable<Iteration> {
|
||||
|
||||
public static final Iteration SR24 = new Iteration("SR23", null);
|
||||
|
||||
@@ -19,10 +19,13 @@ package org.springframework.data.release.model;
|
||||
* A {@link Version} tied to an {@link Iteration}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public interface IterationVersion extends VersionAware {
|
||||
|
||||
Iteration getIteration();
|
||||
|
||||
boolean isBranchVersion();
|
||||
|
||||
boolean usesModifierVersionFormat();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import lombok.RequiredArgsConstructor;
|
||||
*/
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
@EqualsAndHashCode
|
||||
public class ModuleIteration implements IterationVersion, ProjectAware{
|
||||
public class ModuleIteration implements IterationVersion, ProjectAware {
|
||||
|
||||
private final @Getter Module module;
|
||||
private final @Getter TrainIteration trainIteration;
|
||||
@@ -75,6 +75,15 @@ public class ModuleIteration implements IterationVersion, ProjectAware{
|
||||
return getIteration().isServiceIteration() || trainIteration.getTrain().isAlwaysUseBranch();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.release.model.IterationVersion#usesModifierVersionFormat()
|
||||
*/
|
||||
@Override
|
||||
public boolean usesModifierVersionFormat() {
|
||||
return trainIteration.getTrain().usesCalver();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link String} representation of the logical version of the {@link ModuleIteration}. This will
|
||||
* abbreviate trailing zeros and not include the release train name.
|
||||
@@ -103,15 +112,34 @@ public class ModuleIteration implements IterationVersion, ProjectAware{
|
||||
Iteration iteration = trainIteration.getIteration();
|
||||
|
||||
if (iteration.isServiceIteration()) {
|
||||
builder.append(" (").append(trainIteration.toString());
|
||||
builder.append(" (");
|
||||
if (getTrain().usesCalver()) {
|
||||
builder.append(trainIteration.getName());
|
||||
} else {
|
||||
builder.append(trainIteration.toString());
|
||||
}
|
||||
} else {
|
||||
builder.append(" ").append(iteration.getName()).append(" (");
|
||||
builder.append(trainIteration.getTrain().getName());
|
||||
builder.append(trainIteration.getName());
|
||||
}
|
||||
|
||||
return builder.append(")").toString();
|
||||
}
|
||||
|
||||
public String getReleaseVersionString() {
|
||||
|
||||
if (getTrain().usesCalver()) {
|
||||
|
||||
if (getIteration().isServiceIteration() || getIteration().isGAIteration()) {
|
||||
return getTrainIteration().getCalver().toMajorMinorBugfix();
|
||||
}
|
||||
|
||||
return getTrainIteration().getCalver().toMajorMinorBugfix() + "-" + getIteration().getName();
|
||||
}
|
||||
|
||||
return getTrain().getName() + " " + getIteration().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link String} representation of the logical version of the {@link ModuleIteration}. This will use the
|
||||
* technical version string and append the train iteration.
|
||||
|
||||
@@ -37,12 +37,14 @@ import org.jgrapht.traverse.TopologicalOrderIterator;
|
||||
*/
|
||||
public class Projects {
|
||||
|
||||
public static final Project COMMONS, BUILD, REST, JDBC, JPA, MONGO_DB, NEO4J, SOLR, COUCHBASE, CASSANDRA,
|
||||
public static final Project BOM, COMMONS, BUILD, REST, JDBC, JPA, MONGO_DB, NEO4J, SOLR, COUCHBASE, CASSANDRA,
|
||||
ELASTICSEARCH, R2DBC, REDIS, GEMFIRE, KEY_VALUE, ENVERS, LDAP, GEODE;
|
||||
public static final List<Project> PROJECTS;
|
||||
|
||||
static {
|
||||
|
||||
BOM = new Project("DATABOM", "BOM", Tracker.GITHUB);
|
||||
|
||||
BUILD = new Project("DATABUILD", "Build", Tracker.GITHUB) //
|
||||
.withAdditionalArtifacts(ArtifactCoordinates.forGroupId("org.springframework.data.build")
|
||||
.artifacts("spring-data-build-parent", "spring-data-build-resources")
|
||||
|
||||
@@ -28,7 +28,8 @@ import java.util.List;
|
||||
public class ReleaseTrains {
|
||||
|
||||
public static final List<Train> TRAINS;
|
||||
public static final Train CODD, DIJKSTRA, EVANS, FOWLER, GOSLING, HOPPER, INGALLS, KAY, LOVELACE, MOORE, NEUMANN;
|
||||
public static final Train CODD, DIJKSTRA, EVANS, FOWLER, GOSLING, HOPPER, INGALLS, KAY, LOVELACE, MOORE, NEUMANN,
|
||||
OCKHAM;
|
||||
|
||||
static {
|
||||
|
||||
@@ -63,11 +64,15 @@ public class ReleaseTrains {
|
||||
new Module(JDBC, "2.0"), //
|
||||
new Module(R2DBC, "1.1")) //
|
||||
.filterModules(module -> !module.getProject().equals(GEMFIRE))
|
||||
.withIterations(new Train.Iterations(M1, M2, M3, M4, RC1, RC2, GA));
|
||||
.withIterations(new Train.Iterations(M1, M2, M3, M4, RC1, RC2, GA, SR1, SR2, SR3, SR4, SR5));
|
||||
|
||||
OCKHAM = NEUMANN.next("Ockham", Transition.MINOR).withCalver("2020.0.0")
|
||||
.withIterations(new Train.Iterations(M1, M2, M3, M4, RC1, RC2, GA, SR1, SR2, SR3, SR4, SR5));
|
||||
|
||||
// Trains
|
||||
|
||||
TRAINS = Arrays.asList(CODD, DIJKSTRA, EVANS, FOWLER, GOSLING, HOPPER, INGALLS, KAY, LOVELACE, MOORE, NEUMANN);
|
||||
TRAINS = Arrays.asList(CODD, DIJKSTRA, EVANS, FOWLER, GOSLING, HOPPER, INGALLS, KAY, LOVELACE, MOORE, NEUMANN,
|
||||
OCKHAM);
|
||||
}
|
||||
|
||||
private static Train codd() {
|
||||
|
||||
@@ -32,7 +32,7 @@ public enum Tracker {
|
||||
|
||||
private final String ticketPattern;
|
||||
|
||||
public static final String releaseTicketSummary(ModuleIteration moduleIteration) {
|
||||
public static String releaseTicketSummary(ModuleIteration moduleIteration) {
|
||||
return "Release " + moduleIteration.getMediumVersionString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import java.util.stream.Stream;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import org.springframework.data.util.Streamable;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -49,6 +50,7 @@ public class Train implements Streamable<Module> {
|
||||
|
||||
private final String name;;
|
||||
private final Modules modules;
|
||||
private @Nullable Version calver;
|
||||
private @With Iterations iterations;
|
||||
private @With boolean alwaysUseBranch;
|
||||
|
||||
@@ -57,7 +59,7 @@ public class Train implements Streamable<Module> {
|
||||
}
|
||||
|
||||
public Train(String name, Collection<Module> modules) {
|
||||
this(name, Modules.of(modules), Iterations.DEFAULT, false);
|
||||
this(name, Modules.of(modules), null, Iterations.DEFAULT, false);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -106,17 +108,18 @@ public class Train implements Streamable<Module> {
|
||||
|
||||
public Train next(String name, Transition transition, Module... additionalModules) {
|
||||
|
||||
Set<Module> collect = Stream.concat(modules.stream(), Stream.of(additionalModules)).//
|
||||
Set<Module> modules = Stream.concat(this.modules.stream(), Stream.of(additionalModules)).//
|
||||
map(module -> Arrays.stream(additionalModules).//
|
||||
reduce(module.next(transition),
|
||||
(it, additionalModule) -> it.hasSameProjectAs(additionalModule) ? additionalModule : it))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
return new Train(name, collect);
|
||||
return new Train(name, Modules.of(modules), calver, iterations, alwaysUseBranch);
|
||||
}
|
||||
|
||||
public Train filterModules(Predicate<Module> filterPredicate) {
|
||||
return new Train(name, getModules().stream().filter(filterPredicate).collect(Collectors.toList()));
|
||||
return new Train(name, Modules.of(getModules().stream().filter(filterPredicate).collect(Collectors.toList())),
|
||||
calver, iterations, alwaysUseBranch);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,6 +164,14 @@ public class Train implements Streamable<Module> {
|
||||
return ArtifactVersion.of(new ModuleIteration(module, new TrainIteration(this, iteration)));
|
||||
}
|
||||
|
||||
public boolean usesCalver() {
|
||||
return calver != null;
|
||||
}
|
||||
|
||||
public Train withCalver(String calverVersion) {
|
||||
return new Train(name, modules, Version.parse(calverVersion), iterations, alwaysUseBranch);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
|
||||
@@ -64,12 +64,61 @@ public class TrainIteration implements Streamable<ModuleIteration> {
|
||||
return train.getModuleIteration(module.getProject(), previousIteration);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
||||
if (getTrain().usesCalver()) {
|
||||
return getCalver().toMajorMinorBugfix();
|
||||
}
|
||||
|
||||
return getTrain().getName();
|
||||
}
|
||||
|
||||
public String getReleaseTrainNameAndVersion() {
|
||||
|
||||
if (getTrain().usesCalver()) {
|
||||
|
||||
if (getIteration().isMilestone() || getIteration().isReleaseCandidate()) {
|
||||
return String.format("%s-%s", getCalver(), iteration);
|
||||
}
|
||||
|
||||
return getCalver().toString();
|
||||
}
|
||||
|
||||
if (iteration.isGAIteration()) {
|
||||
return String.format("%s-RELEASE", getTrain().getName());
|
||||
}
|
||||
|
||||
return String.format("%s-%s", getTrain().getName(), iteration);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s %s", train.getName(), iteration.getName());
|
||||
return String.format("%s %s", getName(), iteration.getName());
|
||||
}
|
||||
|
||||
public Version getCalver() {
|
||||
|
||||
Version version = getTrain().getCalver();
|
||||
|
||||
if (getIteration().isServiceIteration()) {
|
||||
return version.withBugfix(getIteration().getBugfixValue());
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
public String getNextBugfixName() {
|
||||
|
||||
Version version = getTrain().getCalver();
|
||||
int currentBugfixLevel = 0;
|
||||
if (getIteration().isServiceIteration()) {
|
||||
currentBugfixLevel = getIteration().getBugfixValue();
|
||||
}
|
||||
|
||||
return version.withBugfix(currentBugfixLevel + 1).toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,8 @@ class MaintainedVersion implements Comparable<MaintainedVersion> {
|
||||
Assert.notNull(module, "Module must not be null!");
|
||||
Assert.notNull(train, "Train must not be null!");
|
||||
|
||||
ArtifactVersion snapshotVersion = ArtifactVersion.of(module.getVersion()).getSnapshotVersion();
|
||||
ArtifactVersion snapshotVersion = ArtifactVersion.of(module.getVersion()).withModifierFormat(train.usesCalver())
|
||||
.getSnapshotVersion();
|
||||
|
||||
return MaintainedVersion.of(module.getProject(), snapshotVersion, train);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.Locale;
|
||||
import org.springframework.data.release.build.MavenArtifact;
|
||||
import org.springframework.data.release.model.ArtifactVersion;
|
||||
import org.springframework.data.release.model.Projects;
|
||||
import org.springframework.data.release.model.Train;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
@@ -143,18 +144,33 @@ class ProjectMetadata {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the version to use. For the build project thats the release train name, for everything else the artifact
|
||||
* Return the version to use. For the build project that's the release train name, for everything else the artifact
|
||||
* version.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getVersion() {
|
||||
|
||||
if (Projects.BUILD.equals(version.getProject())) {
|
||||
return String.format("%s-%s", version.getTrain().getName(), version.getVersion().getReleaseTrainSuffix());
|
||||
ArtifactVersion version = this.version.getVersion();
|
||||
|
||||
if (Projects.BUILD.equals(this.version.getProject())) {
|
||||
|
||||
Train train = this.version.getTrain();
|
||||
|
||||
if (train.usesCalver()) {
|
||||
|
||||
if (version.isBugFixVersion() || version.isReleaseVersion()) {
|
||||
return train.getCalver().toMajorMinorBugfix();
|
||||
}
|
||||
|
||||
return String.format("%s-%s", train.getName(), version.getReleaseTrainSuffix());
|
||||
}
|
||||
|
||||
return String.format("%s-%s", train.getName(),
|
||||
version.isReleaseVersion() && !version.isBugFixVersion() ? "RELEASE" : version.getReleaseTrainSuffix());
|
||||
}
|
||||
|
||||
return version.getVersion().toString();
|
||||
return version.toString();
|
||||
}
|
||||
|
||||
public class Repository {
|
||||
|
||||
Reference in New Issue
Block a user