diff --git a/docs/pom.xml b/docs/pom.xml
index b2edc116..9f54d0db 100644
--- a/docs/pom.xml
+++ b/docs/pom.xml
@@ -5,7 +5,7 @@
org.springframework.cloud.internal
releaser-parent
- 1.0.0.BUILD-SNAPSHOT
+ 2.0.0-SNAPSHOT
releaser-docs
pom
diff --git a/pom.xml b/pom.xml
index 04eca340..82253497 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
org.springframework.cloud.internal
releaser-parent
- 1.0.0.BUILD-SNAPSHOT
+ 2.0.0-SNAPSHOT
pom
diff --git a/projects/pom.xml b/projects/pom.xml
index 7a46f4a5..097e0054 100644
--- a/projects/pom.xml
+++ b/projects/pom.xml
@@ -5,13 +5,13 @@
4.0.0
releaser-projects
- 1.0.0.BUILD-SNAPSHOT
+ 2.0.0-SNAPSHOT
pom
org.springframework.cloud.internal
releaser-parent
- 1.0.0.BUILD-SNAPSHOT
+ 2.0.0-SNAPSHOT
..
diff --git a/projects/reactor/pom.xml b/projects/reactor/pom.xml
index 7b827a0c..a14e88bd 100644
--- a/projects/reactor/pom.xml
+++ b/projects/reactor/pom.xml
@@ -10,7 +10,7 @@
org.springframework.cloud.internal
releaser-projects
- 1.0.0.BUILD-SNAPSHOT
+ 2.0.0-SNAPSHOT
..
diff --git a/projects/spring-cloud-stream/pom.xml b/projects/spring-cloud-stream/pom.xml
index 04620a1c..c708127c 100644
--- a/projects/spring-cloud-stream/pom.xml
+++ b/projects/spring-cloud-stream/pom.xml
@@ -10,7 +10,7 @@
org.springframework.cloud.internal
releaser-projects
- 1.0.0.BUILD-SNAPSHOT
+ 2.0.0-SNAPSHOT
..
diff --git a/projects/spring-cloud-stream/src/main/resources/application.yml b/projects/spring-cloud-stream/src/main/resources/application.yml
index 829c1235..570ac2fb 100644
--- a/projects/spring-cloud-stream/src/main/resources/application.yml
+++ b/projects/spring-cloud-stream/src/main/resources/application.yml
@@ -25,10 +25,7 @@ releaser:
deploy-command: "./mvnw deploy -DskipTests -B -Pfast,deploy {{systemProps}}"
deploy-guides-command: "./mvnw clean verify deploy -B -Pguides,integration -pl guides {{systemProps}}"
publish-docs-commands:
- - "mkdir -p target"
- - "wget https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/docs/src/main/asciidoc/ghpages.sh -O target/gh-pages.sh"
- - "chmod +x target/gh-pages.sh"
- - "./target/gh-pages.sh -v {{version}} -c"
+ - "./mvnw deploy -DskipTests -B -Pfast,deploy,docs {{systemProps}}"
generate-release-train-docs-command: "bash release_train.sh --retrieveversions --version {{version}} --ghpages --auto"
sagan:
update-sagan: true
diff --git a/projects/spring-cloud/pom.xml b/projects/spring-cloud/pom.xml
index 5306678f..30071afd 100644
--- a/projects/spring-cloud/pom.xml
+++ b/projects/spring-cloud/pom.xml
@@ -10,7 +10,7 @@
org.springframework.cloud.internal
releaser-projects
- 1.0.0.BUILD-SNAPSHOT
+ 2.0.0-SNAPSHOT
..
diff --git a/projects/spring-cloud/src/main/resources/application.yml b/projects/spring-cloud/src/main/resources/application.yml
index 3d66c525..aa8f2a48 100644
--- a/projects/spring-cloud/src/main/resources/application.yml
+++ b/projects/spring-cloud/src/main/resources/application.yml
@@ -64,10 +64,7 @@ releaser:
deploy-command: "./mvnw deploy -DskipTests -B -Pfast,deploy {{systemProps}}"
deploy-guides-command: "./mvnw clean verify deploy -B -Pguides,integration -pl guides {{systemProps}}"
publish-docs-commands:
- - "mkdir -p target"
- - "wget https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/docs/src/main/asciidoc/ghpages.sh -O target/gh-pages.sh"
- - "chmod +x target/gh-pages.sh"
- - "./target/gh-pages.sh -v {{version}} -c"
+ - "./mvnw deploy -DskipTests -B -Pfast,deploy,docs {{systemProps}}"
generate-release-train-docs-command: "bash release_train.sh --retrieveversions --version {{version}} --ghpages --auto"
system-properties: ""
wait-time-in-minutes: 20
diff --git a/projects/spring-cloud/src/test/java/releaser/cloud/spring/single/SpringSingleProjectAcceptanceTests.java b/projects/spring-cloud/src/test/java/releaser/cloud/spring/single/SpringSingleProjectAcceptanceTests.java
index d8f33802..afa46dfa 100644
--- a/projects/spring-cloud/src/test/java/releaser/cloud/spring/single/SpringSingleProjectAcceptanceTests.java
+++ b/projects/spring-cloud/src/test/java/releaser/cloud/spring/single/SpringSingleProjectAcceptanceTests.java
@@ -122,11 +122,11 @@ public class SpringSingleProjectAcceptanceTests
Iterator iterator = commits.iterator();
tagIsPresentInOrigin(origin, "v2.1.2.RELEASE");
commitIsPresent(iterator,
- "Bumping versions to 2.1.3.BUILD-SNAPSHOT after release");
+ "Bumping versions to 2.1.3.SNAPSHOT after release");
commitIsPresent(iterator, "Going back to snapshots");
commitIsPresent(iterator, "Update SNAPSHOT to 2.1.2.RELEASE");
- pomVersionIsEqualTo(project, "2.1.3.BUILD-SNAPSHOT");
- consulPomParentVersionIsEqualTo(project, "2.1.3.BUILD-SNAPSHOT");
+ pomVersionIsEqualTo(project, "2.1.3.SNAPSHOT");
+ consulPomParentVersionIsEqualTo(project, "2.1.3.SNAPSHOT");
then(gitHubHandler.closedMilestones).isTrue();
then(emailTemplate()).doesNotExist();
then(blogTemplate()).doesNotExist();
@@ -187,10 +187,10 @@ public class SpringSingleProjectAcceptanceTests
tagIsPresentInOrigin(origin, "v2.1.6.RELEASE");
// we're running against camden sc-release
commitIsPresent(iterator,
- "Bumping versions to 2.1.7.BUILD-SNAPSHOT after release");
+ "Bumping versions to 2.1.7.SNAPSHOT after release");
commitIsPresent(iterator, "Going back to snapshots");
commitIsPresent(iterator, "Update SNAPSHOT to 2.1.6.RELEASE");
- pomVersionIsEqualTo(project, "2.1.7.BUILD-SNAPSHOT");
+ pomVersionIsEqualTo(project, "2.1.7.SNAPSHOT");
pomParentVersionIsEqualTo(project, "spring-cloud-build-dependencies",
"2.1.6.RELEASE");
then(gitHubHandler.closedMilestones).isTrue();
@@ -249,7 +249,7 @@ public class SpringSingleProjectAcceptanceTests
Iterable commits = listOfCommits(project);
tagIsPresentInOrigin(origin, "v1.2.0.RC1");
commitIsNotPresent(commits,
- "Bumping versions to 1.2.1.BUILD-SNAPSHOT after release");
+ "Bumping versions to 1.2.1.SNAPSHOT after release");
Iterator iterator = listOfCommits(project).iterator();
commitIsPresent(iterator, "Going back to snapshots");
commitIsPresent(iterator, "Update SNAPSHOT to 1.2.0.RC1");
diff --git a/releaser-core/pom.xml b/releaser-core/pom.xml
index bdfd71aa..44fd792e 100644
--- a/releaser-core/pom.xml
+++ b/releaser-core/pom.xml
@@ -10,7 +10,7 @@
org.springframework.cloud.internal
releaser-parent
- 1.0.0.BUILD-SNAPSHOT
+ 2.0.0-SNAPSHOT
..
diff --git a/releaser-core/src/main/java/releaser/internal/ReleaserProperties.java b/releaser-core/src/main/java/releaser/internal/ReleaserProperties.java
index 143fd9b2..a0110994 100644
--- a/releaser-core/src/main/java/releaser/internal/ReleaserProperties.java
+++ b/releaser-core/src/main/java/releaser/internal/ReleaserProperties.java
@@ -966,11 +966,8 @@ public class ReleaserProperties implements Serializable {
* Command to be executed to publish documentation. If present "{{version}}" will
* be replaced by the provided version.
*/
- private String[] publishDocsCommands = { "mkdir -p target",
- "wget https://raw.githubusercontent.com/spring-cloud/"
- + "spring-cloud-build/master/"
- + "docs/src/main/asciidoc/ghpages.sh -O target/gh-pages.sh",
- "chmod +x target/gh-pages.sh", "./target/gh-pages.sh -v {{version}} -c" };
+ private String[] publishDocsCommands = {
+ "./mvnw deploy -DskipTests -B -Pfast,deploy,docs -pl docs {{systemProps}}" };
/**
* Command to be executed to generate release train documentation.
diff --git a/releaser-core/src/main/java/releaser/internal/docs/ReleaseTrainContentsUpdater.java b/releaser-core/src/main/java/releaser/internal/docs/ReleaseTrainContentsUpdater.java
index f7bdd3aa..400ef564 100644
--- a/releaser-core/src/main/java/releaser/internal/docs/ReleaseTrainContentsUpdater.java
+++ b/releaser-core/src/main/java/releaser/internal/docs/ReleaseTrainContentsUpdater.java
@@ -142,8 +142,7 @@ class ReleaseTrainContentsUpdater {
private boolean isThisReleaseTrainVersionNewer(ProjectVersion releaseTrain,
String releaseVersionFromCurrentFile) {
if (StringUtils.hasText(releaseVersionFromCurrentFile)) {
- return releaseTrain
- .compareToReleaseTrainName(releaseVersionFromCurrentFile) > 0;
+ return releaseTrain.compareToReleaseTrain(releaseVersionFromCurrentFile) > 0;
}
return true;
}
@@ -229,9 +228,8 @@ class ReleaseTrainContentsParser {
// We want to find only headers like # Finchley.RELEASE and not any
// custom headers
.filter(s -> s.trim().startsWith("#") && s.contains("."))
- .map(s -> s.substring(1).trim())
- .filter(s -> new ProjectVersion("foo", s).isValid()).findFirst()
- .orElse("");
+ .map(s -> s.substring(1).trim()).filter(ProjectVersion::isValid)
+ .findFirst().orElse("");
}
catch (IOException e) {
throw new IllegalStateException(e);
diff --git a/releaser-core/src/main/java/releaser/internal/project/ProjectVersion.java b/releaser-core/src/main/java/releaser/internal/project/ProjectVersion.java
index bd0d8c87..bf621e76 100644
--- a/releaser-core/src/main/java/releaser/internal/project/ProjectVersion.java
+++ b/releaser-core/src/main/java/releaser/internal/project/ProjectVersion.java
@@ -88,6 +88,15 @@ public class ProjectVersion implements Comparable, Serializable
this.releaseType = toReleaseType();
}
+ // for version comparison
+ ProjectVersion(String version) {
+ this.projectName = "";
+ this.version = version;
+ this.groupId = "";
+ this.artifactId = "";
+ this.releaseType = toReleaseType();
+ }
+
public ProjectVersion(File project) {
File buildGradle = new File(project, "build.gradle");
if (buildGradle.exists()) {
@@ -169,38 +178,46 @@ public class ProjectVersion implements Comparable, Serializable
}
private SplitVersion assertVersion() {
- if (this.version == null) {
+ return assertVersion(this.version);
+ }
+
+ private SplitVersion assertVersion(String version) {
+ if (version == null || StringUtils.isEmpty(version)) {
throw new IllegalStateException("Version can't be null!");
}
- SplitVersion splitByHyphen = tryHyphenSeparatedVersion();
+ else if (version.endsWith(".") || version.endsWith("-")) {
+ throw new IllegalStateException("Version can't end with a delimiter!");
+ }
+ SplitVersion splitByHyphen = tryHyphenSeparatedVersion(version);
if (splitByHyphen != null) {
return splitByHyphen;
}
- return dotSeparatedReleaseTrainsAndVersions();
+ return dotSeparatedReleaseTrainsAndVersions(version);
}
- private SplitVersion tryHyphenSeparatedVersion() {
+ private SplitVersion tryHyphenSeparatedVersion(String version) {
// Check for hyphen separated BOMs versioning
// Dysprosium-BUILD-SNAPSHOT or Dysprosium-RELEASE
// 1.0.0-BUILD-SNAPSHOT or 1.0.0-RELEASE
- String[] splitByHyphen = this.version.split("\\-");
+ // 1.0.0-SNAPSHOT or 1.0.0-RELEASE
+ String[] splitByHyphen = version.split("\\-");
int splitByHyphens = splitByHyphen.length;
int numberOfHyphens = splitByHyphens - 1;
- int indexOfFirstHyphen = this.version.indexOf("-");
- boolean buildSnapshot = this.version.endsWith("BUILD-SNAPSHOT");
+ int indexOfFirstHyphen = version.indexOf("-");
+ boolean buildSnapshot = version.endsWith("BUILD-SNAPSHOT");
if (numberOfHyphens == 1 && !buildSnapshot
|| (numberOfHyphens > 1 && buildSnapshot)) {
// Dysprosium or 1.0.0
- String versionName = this.version.substring(0, indexOfFirstHyphen);
+ String versionName = version.substring(0, indexOfFirstHyphen);
boolean hasDots = versionName.contains(".");
// BUILD-SNAPSHOT
- String versionType = this.version.substring(indexOfFirstHyphen + 1);
+ String versionType = version.substring(indexOfFirstHyphen + 1);
// Dysprosium-BUILD-SNAPSHOT
- if (splitByHyphens > 1 && !hasDots && validVersionType()) {
+ if (splitByHyphens > 1 && !hasDots && validVersionType(version)) {
return SplitVersion.hyphen(versionName, versionType);
}
// Dysprosium-RELEASE
- else if (splitByHyphens == 1 && !hasDots && validVersionType()) {
+ else if (splitByHyphens == 1 && !hasDots && validVersionType(version)) {
return SplitVersion.hyphen(splitByHyphen[0], splitByHyphen[1]);
}
// 1.0.0-RELEASE or 1.0.0-BUILD-SNAPSHOT
@@ -210,14 +227,14 @@ public class ProjectVersion implements Comparable, Serializable
}
else {
throw new UnsupportedOperationException(
- "Unknown version [" + this.version + "]");
+ "Unknown version [" + version + "]");
}
}
return null;
}
- private boolean validVersionType() {
- return VALID_PATTERNS.stream().anyMatch(p -> p.matcher(this.version).matches());
+ private boolean validVersionType(String version) {
+ return VALID_PATTERNS.stream().anyMatch(p -> p.matcher(version).matches());
}
private String[] combinedArrays(String versionName, String versionType) {
@@ -231,8 +248,12 @@ public class ProjectVersion implements Comparable, Serializable
}
private SplitVersion dotSeparatedReleaseTrainsAndVersions() {
+ return dotSeparatedReleaseTrainsAndVersions(this.version);
+ }
+
+ private SplitVersion dotSeparatedReleaseTrainsAndVersions(String version) {
// Hoxton.BUILD-SNAPSHOT or 1.0.0.BUILD-SNAPSHOT
- String[] splitVersion = this.version.split("\\.");
+ String[] splitVersion = version.split("\\.");
return SplitVersion.dot(splitVersion);
}
@@ -244,15 +265,24 @@ public class ProjectVersion implements Comparable, Serializable
public String postReleaseSnapshotVersion() {
SplitVersion splitVersion = assertVersion();
if (isReleaseOrServiceRelease()) {
- return bumpedVersion(splitVersion).withBuildSnapshot().print();
+ return bumpedVersion(splitVersion).withSnapshot().print();
}
- return splitVersion.withBuildSnapshot().print();
+ return splitVersion.withSnapshot().print();
}
public String groupId() {
return this.groupId;
}
+ public static boolean isValid(String version) {
+ try {
+ return new ProjectVersion(version).isValid();
+ }
+ catch (IllegalStateException e) {
+ return false;
+ }
+ }
+
public boolean isValid() {
try {
assertVersion();
@@ -391,6 +421,11 @@ public class ProjectVersion implements Comparable, Serializable
return splitVersion.isReleaseTrain();
}
+ public boolean isOldReleaseTrain() {
+ SplitVersion splitVersion = assertVersion();
+ return splitVersion.isOldReleaseTrain();
+ }
+
public boolean isReleaseOrServiceRelease() {
return isRelease() || isServiceRelease();
}
@@ -412,6 +447,31 @@ public class ProjectVersion implements Comparable, Serializable
else if (isServiceRelease()) {
return ReleaseType.SR;
}
+ else if (isSnapshot()) {
+ return ReleaseType.SNAPSHOT;
+ }
+ return releaseTypeForReleaseTrain();
+ }
+
+ /*
+ * 2020.0.0-SNAPSHOT 2020.0.0-M1 2020.0.0-M4 2020.0.0-RC1 (those are done already)
+ * 2020.0.0 -> this is RELEASE (no RELEASE suffix) 2020.0.1 -> this is SR1 (no SR1
+ * suffix)
+ */
+ private ReleaseType releaseTypeForReleaseTrain() {
+ try {
+ SplitVersion splitVersion = assertVersion();
+ if (StringUtils.isEmpty(splitVersion.suffix)
+ && StringUtils.hasText(splitVersion.patch)) {
+ if ("0".equals(splitVersion.patch)) {
+ return ReleaseType.RELEASE;
+ }
+ return ReleaseType.SR;
+ }
+ }
+ catch (IllegalStateException ex) {
+ return ReleaseType.SNAPSHOT;
+ }
return ReleaseType.SNAPSHOT;
}
@@ -469,9 +529,16 @@ public class ProjectVersion implements Comparable, Serializable
public boolean isSameReleaseTrainName(String version) {
assertVersionSet();
- String[] splitThis = this.version.split("\\.");
- String[] splitThat = version.split("\\.");
- return splitThis[0].compareToIgnoreCase(splitThat[0]) == 0;
+ SplitVersion thisVersion = assertVersion();
+ SplitVersion thatVersion = assertVersion(version);
+ if (thisVersion.isOldReleaseTrain() && thatVersion.isOldReleaseTrain()) {
+ return thisVersion.major.compareToIgnoreCase(thatVersion.major) == 0;
+ }
+ else if (thisVersion.isOldReleaseTrain()) {
+ return false;
+ }
+ return thisVersion.major.equals(thatVersion.major)
+ && thisVersion.minor.equals(thatVersion.minor);
}
private void assertVersionSet() {
@@ -480,20 +547,9 @@ public class ProjectVersion implements Comparable, Serializable
}
}
- public int compareToReleaseTrainName(String version) {
- assertVersionSet();
- String[] split = version.split("\\.");
- String thatName = split[0];
- String thatValue = split.length > 1 ? split[1] : "";
- String[] thisSplit = this.version.split("\\.");
- String thisName = thisSplit[0];
- String thisValue = thisSplit.length > 1 ? thisSplit[1] : "";
- int nameComparison = thisName.compareTo(thatName);
- if (nameComparison != 0) {
- return nameComparison;
- }
- return new TrainVersionNumber(thisValue)
- .compareTo(new TrainVersionNumber(thatValue));
+ public int compareToReleaseTrain(String version) {
+ return new TrainVersionNumber(this)
+ .compareTo(new TrainVersionNumber(new ProjectVersion(version)));
}
/**
@@ -547,13 +603,15 @@ public class ProjectVersion implements Comparable, Serializable
return this.version.compareTo(o.version);
}
- private static final class SplitVersion {
+ static final class SplitVersion {
private static final String DOT = ".";
private static final String HYPHEN = "-";
- private static final String BUILD_SNAPSHOT_SUFFIX = "BUILD-SNAPSHOT";
+ private static final String SNAPSHOT_SUFFIX = "SNAPSHOT";
+
+ private static final String LEGACY_SNAPSHOT_SUFFIX = "BUILD-SNAPSHOT";
final String major;
@@ -609,10 +667,13 @@ public class ProjectVersion implements Comparable, Serializable
}
private static SplitVersion version(String[] args, String delimiter) {
+ // Hoxton.SR4
if (args.length == 2) {
return new SplitVersion(args[0], "", "", delimiter, args[1]);
}
- else if (args.length == 3) {
+ // 1.0.RELEASE
+ // but not 1.0.3
+ else if (args.length == 3 && notNumeric(args[2])) {
return new SplitVersion(args[0], args[1], "", delimiter, args[2]);
}
return new SplitVersion(args, delimiter);
@@ -626,17 +687,20 @@ public class ProjectVersion implements Comparable, Serializable
}
private boolean isInvalid() {
- return wrongReleaseTrainVersion() || wrongLibraryVersion() || wrongDelimiter()
- || noSuffix();
+ return wrongDelimiter() || tooFewElements();
}
- private boolean noSuffix() {
- return StringUtils.isEmpty(suffix);
- }
-
- // Hoxton.BUILD-SNAPSHOT or Hoxton-BUILD-SNAPSHOT
+ // Hoxton.BUILD-SNAPSHOT or Hoxton-BUILD-SNAPSHOT or 2020.x.x
private boolean isReleaseTrain() {
- return !isNumeric(this.major);
+ return isOldReleaseTrain() || calverReleaseTrain();
+ }
+
+ private boolean calverReleaseTrain() {
+ return Integer.parseInt(this.major) >= 2020;
+ }
+
+ private boolean isOldReleaseTrain() {
+ return notNumeric(this.major);
}
private SplitVersion fullVersionWithIncrementedPatch() {
@@ -645,85 +709,132 @@ public class ProjectVersion implements Comparable, Serializable
delimiter, suffix);
}
- private String gav() {
- // Finchley
- if (StringUtils.isEmpty(minor)) {
- return String.format("%s", major);
- }
- // 1.0.1
- return String.format("%s.%s.%s", major, minor, patch);
- }
-
- private String print() {
+ String print() {
// Finchley.SR2
if (StringUtils.isEmpty(minor)) {
- return String.format("%s%s%s", major, delimiter, suffix);
+ return StringUtils.isEmpty(suffix) ? major
+ : String.format("%s%s%s", major, delimiter, suffix);
+ }
+ else if (StringUtils.isEmpty(suffix)) {
+ return String.format("%s.%s.%s", major, minor, patch);
}
return String.format("%s.%s.%s%s%s", major, minor, patch, delimiter, suffix);
}
- private boolean isNumeric(String string) {
- return string.matches("[0-9]+");
+ private static boolean notNumeric(String string) {
+ return !string.matches("[0-9]+");
}
private boolean wrongDelimiter() {
return !(DOT.equals(this.delimiter) || HYPHEN.equals(this.delimiter));
}
- private boolean wrongLibraryVersion() {
- // GOOD:
- // 1.2.3.RELEASE, 1.2.3-RELEASE, Hoxton.BUILD-SNAPSHOT, Hoxton-RELEASE
- // must have
- // either major and suffix (release train)
- // major, minor, patch and suffix
- return isNumeric(major) && (StringUtils.isEmpty(minor)
- || StringUtils.isEmpty(patch) || StringUtils.isEmpty(suffix)
- || StringUtils.isEmpty(delimiter));
+ private boolean tooFewElements() {
+ // 1 is wrong but Finchley-SR3 is ok
+ return StringUtils.isEmpty(minor) && StringUtils.isEmpty(patch)
+ && StringUtils.isEmpty(suffix);
}
- private boolean wrongReleaseTrainVersion() {
- // BAD: 1.EXAMPLE, GOOD: Hoxton.RELEASE
- return isNumeric(major) && StringUtils.isEmpty(suffix);
+ private SplitVersion withSnapshot() {
+ return new SplitVersion(major, minor, patch, delimiter, suffix());
}
- private SplitVersion withBuildSnapshot() {
- return new SplitVersion(major, minor, patch, delimiter,
- BUILD_SNAPSHOT_SUFFIX);
+ private String suffix() {
+ if (suffix.endsWith(LEGACY_SNAPSHOT_SUFFIX)) {
+ return LEGACY_SNAPSHOT_SUFFIX;
+ }
+ return SNAPSHOT_SUFFIX;
}
}
-}
+ private static class TrainVersionNumber implements Comparable {
-class TrainVersionNumber implements Comparable {
+ private final ProjectVersion version;
- private final String version;
-
- TrainVersionNumber(String version) {
- this.version = version;
- }
-
- @Override
- public int compareTo(TrainVersionNumber o) {
- String thisLower = this.version.toLowerCase();
- char thisFirst = thisLower.isEmpty() ? ' ' : thisLower.charAt(0);
- String thatLower = o.version.toLowerCase();
- char thatFirst = thatLower.isEmpty() ? ' ' : thatLower.charAt(0);
- // B < M < RC < R < S
- int charComparison = Character.compare(thisFirst, thatFirst);
- if (charComparison != 0) {
- return charComparison;
+ TrainVersionNumber(ProjectVersion version) {
+ this.version = version;
}
- String thisVersion = this.version.replaceAll("\\D+", "");
- boolean thisVersionEmpty = StringUtils.isEmpty(thisVersion);
- String thatVersion = o.version.replaceAll("\\D+", "");
- boolean thatVersionEmpty = StringUtils.isEmpty(thatVersion);
- if (thisVersionEmpty || thatVersionEmpty) {
+
+ @Override
+ public int compareTo(TrainVersionNumber o) {
+ ProjectVersion thisVersion = this.version;
+ ProjectVersion thatVersion = o.version;
+ // 2020.0.0 vs ""
+ if (!thatVersion.isValid() && thisVersion.isValid()) {
+ return 1;
+ // "" vs 2020.0.0
+ }
+ else if (!thisVersion.isValid() && thatVersion.isValid()) {
+ return -1;
+ }
+ boolean thisOldTrain = isOldReleaseTrain(thisVersion);
+ boolean thatOldTrain = isOldReleaseTrain(thatVersion);
+ if (thisOldTrain && thatOldTrain) {
+ return letterBasedReleaseTrainComparison(o);
+ }
+ else if (thisOldTrain) {
+ return compareWithOldTrain(thisVersion, thatVersion);
+ }
+ else if (thatOldTrain) {
+ return -1 * compareWithOldTrain(thisVersion, thatVersion);
+ }
+ // new train comparison
return thisVersion.compareTo(thatVersion);
}
- Integer thisNumber = Integer.valueOf(thisVersion);
- Integer thatNumber = Integer.valueOf(thatVersion);
- return thisNumber.compareTo(thatNumber);
+
+ private boolean isOldReleaseTrain(ProjectVersion projectVersion) {
+ try {
+ return projectVersion.isOldReleaseTrain();
+ }
+ catch (IllegalStateException ex) {
+ return false;
+ }
+ }
+
+ private int compareWithOldTrain(ProjectVersion oldTrain,
+ ProjectVersion thatVersion) {
+ // Hoxton.SR5 > 2020.0.0-M5
+ if (oldTrain.isReleaseOrServiceRelease()
+ && !thatVersion.isReleaseOrServiceRelease()) {
+ return 1;
+ }
+ // Hoxton.SR5 < 2020.0.0-RELEASE
+ // Hoxton.M5 < 2020.0.0-M4
+ return -1;
+ }
+
+ private int letterBasedReleaseTrainComparison(TrainVersionNumber o) {
+ String thatName = o.version.major();
+ String thisName = this.version.major();
+ int nameComparison = thisName.compareTo(thatName);
+ if (nameComparison != 0) {
+ return nameComparison;
+ }
+ String thisSuffix = this.version.assertVersion().suffix;
+ String thisValue = thisSuffix;
+ String thisLower = thisValue.toLowerCase();
+ char thisFirst = thisLower.isEmpty() ? ' ' : thisLower.charAt(0);
+ String thatSuffix = o.version.assertVersion().suffix;
+ String thatLower = thatSuffix.toLowerCase();
+ char thatFirst = thatLower.isEmpty() ? ' ' : thatLower.charAt(0);
+ // B < M < RC < R < S
+ int charComparison = Character.compare(thisFirst, thatFirst);
+ if (charComparison != 0) {
+ return charComparison;
+ }
+ String thisVersion = this.version.toString().replaceAll("\\D+", "");
+ boolean thisVersionEmpty = StringUtils.isEmpty(thisVersion);
+ String thatVersion = o.version.toString().replaceAll("\\D+", "");
+ boolean thatVersionEmpty = StringUtils.isEmpty(thatVersion);
+ if (thisVersionEmpty || thatVersionEmpty) {
+ return thisVersion.compareTo(thatVersion);
+ }
+ Integer thisNumber = Integer.valueOf(thisVersion);
+ Integer thatNumber = Integer.valueOf(thatVersion);
+ return thisNumber.compareTo(thatNumber);
+ }
+
}
}
diff --git a/releaser-core/src/test/java/releaser/internal/ReleaserTests.java b/releaser-core/src/test/java/releaser/internal/ReleaserTests.java
index b4897cfa..79a0220d 100644
--- a/releaser-core/src/test/java/releaser/internal/ReleaserTests.java
+++ b/releaser-core/src/test/java/releaser/internal/ReleaserTests.java
@@ -152,8 +152,8 @@ public class ReleaserTests {
.contains("Project was successfully updated")
.contains("Successfully reverted the commit and bumped snapshot versions")
.contains("spring-boot-starter=>3.0.0.RELEASE")
- .contains("spring-cloud-build=>2.0.1.BUILD-SNAPSHOT")
- .contains("changed=>1.0.1.BUILD-SNAPSHOT");
+ .contains("spring-cloud-build=>2.0.1.SNAPSHOT")
+ .contains("changed=>1.0.1.SNAPSHOT");
}
@Test
diff --git a/releaser-core/src/test/java/releaser/internal/buildsystem/ProjectVersionTests.java b/releaser-core/src/test/java/releaser/internal/buildsystem/ProjectVersionTests.java
index 4075e8b5..85681200 100644
--- a/releaser-core/src/test/java/releaser/internal/buildsystem/ProjectVersionTests.java
+++ b/releaser-core/src/test/java/releaser/internal/buildsystem/ProjectVersionTests.java
@@ -84,129 +84,129 @@ public class ProjectVersionTests {
@Test
public void should_throw_exception_if_version_is_not_long_enough() {
- String version = "1.0";
+ String version = "1";
thenThrownBy(() -> projectVersion(version).bumpedVersion())
.isInstanceOf(IllegalStateException.class).hasMessageContaining(
- "Version [1.0] is invalid. Should be of format [1.2.3.A] / [1.2.3-A] or [A.B] / [A-B]");
+ "Version [1] is invalid. Should be of format [1.2.3.A] / [1.2.3-A] or [A.B] / [A-B]");
}
@Test
public void should_bump_version_by_patch_version() {
- String version = "1.0.1.BUILD-SNAPSHOT";
+ String version = "1.0.1-SNAPSHOT";
- then(projectVersion(version).bumpedVersion()).isEqualTo("1.0.2.BUILD-SNAPSHOT");
+ then(projectVersion(version).bumpedVersion()).isEqualTo("1.0.2-SNAPSHOT");
}
@Test
public void should_return_the_previous_version_for_release_train_version() {
- String version = "Edgware.BUILD-SNAPSHOT";
+ String version = "Edgware-SNAPSHOT";
- then(projectVersion(version).bumpedVersion()).isEqualTo("Edgware.BUILD-SNAPSHOT");
+ then(projectVersion(version).bumpedVersion()).isEqualTo("Edgware-SNAPSHOT");
}
@Test
public void should_return_true_for_a_valid_version() {
- then(projectVersion("2020.0.0-SNAPSHOT").isValid()).isTrue();
- then(projectVersion("2020.0.0-M1").isValid()).isTrue();
- then(projectVersion("2020.0.0-RC2").isValid()).isTrue();
- // then(projectVersion("2020.0.0").isValid()).isTrue();
- then(projectVersion("1.0.1.BUILD-SNAPSHOT").isValid()).isTrue();
- then(projectVersion("1.0.3.RC1").isValid()).isTrue();
- then(projectVersion("1.0.4.M1").isValid()).isTrue();
- then(projectVersion("Finchley.BUILD-SNAPSHOT").isValid()).isTrue();
- then(projectVersion("Finchley.RELEASE").isValid()).isTrue();
- then(projectVersion("Finchley.SR1").isValid()).isTrue();
+ then(ProjectVersion.isValid("2020.0.0-SNAPSHOT")).isTrue();
+ then(ProjectVersion.isValid("2020.0.0-M1")).isTrue();
+ then(ProjectVersion.isValid("2020.0.0-RC2")).isTrue();
+ // then(ProjectVersion.isValid("2020.0.0")).isTrue();
+ then(ProjectVersion.isValid("1.0.1-SNAPSHOT")).isTrue();
+ then(ProjectVersion.isValid("1.0.3-RC1")).isTrue();
+ then(ProjectVersion.isValid("1.0.4-M1")).isTrue();
+ then(ProjectVersion.isValid("Finchley-SNAPSHOT")).isTrue();
+ then(ProjectVersion.isValid("Finchley.RELEASE")).isTrue();
+ then(ProjectVersion.isValid("Finchley-SR1")).isTrue();
}
@Test
public void should_return_false_for_an_invalid_version() {
- then(projectVersion("1").isValid()).isFalse();
- then(projectVersion("1.").isValid()).isFalse();
- then(projectVersion("1.0.4.").isValid()).isFalse();
- then(projectVersion("Some random text").isValid()).isFalse();
+ then(ProjectVersion.isValid("1")).isFalse();
+ then(ProjectVersion.isValid("1.")).isFalse();
+ then(ProjectVersion.isValid("1.0.4.")).isFalse();
+ then(ProjectVersion.isValid("Some random text")).isFalse();
}
@Test
public void should_throw_exception_if_version_is_not_long_enough_when_bumping_snapshots() {
- String version = "1.0";
+ String version = "1";
thenThrownBy(() -> projectVersion(version).postReleaseSnapshotVersion())
.isInstanceOf(IllegalStateException.class).hasMessageContaining(
- "Version [1.0] is invalid. Should be of format [1.2.3.A] / [1.2.3-A] or [A.B] / [A-B]");
+ "Version [1] is invalid. Should be of format [1.2.3.A] / [1.2.3-A] or [A.B] / [A-B]");
}
@Test
public void should_throw_exception_when_trying_to_get_major_from_invalid_version() {
- String version = "1.0";
+ String version = "1";
thenThrownBy(() -> projectVersion(version).major())
.isInstanceOf(IllegalStateException.class).hasMessageContaining(
- "Version [1.0] is invalid. Should be of format [1.2.3.A] / [1.2.3-A] or [A.B] / [A-B]");
+ "Version [1] is invalid. Should be of format [1.2.3.A] / [1.2.3-A] or [A.B] / [A-B]");
}
@Test
public void should_get_major_from_version() {
- then(projectVersion("2.0.1.BUILD-SNAPSHOT").major()).isEqualTo("2");
- then(projectVersion("2.0.1.M1").major()).isEqualTo("2");
- then(projectVersion("2.0.1.RC1").major()).isEqualTo("2");
- then(projectVersion("Finchley.SR1").major()).isEqualTo("Finchley");
- then(projectVersion("2020.0.0.M1").major()).isEqualTo("2020");
+ then(projectVersion("2.0.1-SNAPSHOT").major()).isEqualTo("2");
+ then(projectVersion("2.0.1-M1").major()).isEqualTo("2");
+ then(projectVersion("2.0.1-RC1").major()).isEqualTo("2");
+ then(projectVersion("Finchley-SR1").major()).isEqualTo("Finchley");
+ then(projectVersion("2020.0.0-M1").major()).isEqualTo("2020");
// then(projectVersion("2020.0.0").major()).isEqualTo("2020");
}
@Test
public void should_not_bump_version_by_patch_version_when_non_ga_or_sr() {
- then(projectVersion("1.0.1.BUILD-SNAPSHOT").postReleaseSnapshotVersion())
- .isEqualTo("1.0.1.BUILD-SNAPSHOT");
- then(projectVersion("1.0.1.M1").postReleaseSnapshotVersion())
- .isEqualTo("1.0.1.BUILD-SNAPSHOT");
- then(projectVersion("1.0.1.RC1").postReleaseSnapshotVersion())
- .isEqualTo("1.0.1.BUILD-SNAPSHOT");
- then(projectVersion("Finchley.SR1").postReleaseSnapshotVersion())
- .isEqualTo("Finchley.BUILD-SNAPSHOT");
+ then(projectVersion("1.0.1-SNAPSHOT").postReleaseSnapshotVersion())
+ .isEqualTo("1.0.1-SNAPSHOT");
+ then(projectVersion("1.0.1-M1").postReleaseSnapshotVersion())
+ .isEqualTo("1.0.1-SNAPSHOT");
+ then(projectVersion("1.0.1-RC1").postReleaseSnapshotVersion())
+ .isEqualTo("1.0.1-SNAPSHOT");
+ then(projectVersion("Finchley-SR1").postReleaseSnapshotVersion())
+ .isEqualTo("Finchley-SNAPSHOT");
}
@Test
public void should_not_bump_version_by_patch_version_when_non_ga_or_sr_with_hyphen() {
- then(projectVersion("1.0.1-BUILD-SNAPSHOT").postReleaseSnapshotVersion())
- .isEqualTo("1.0.1-BUILD-SNAPSHOT");
+ then(projectVersion("1.0.1-SNAPSHOT").postReleaseSnapshotVersion())
+ .isEqualTo("1.0.1-SNAPSHOT");
then(projectVersion("1.0.1-M1").postReleaseSnapshotVersion())
- .isEqualTo("1.0.1-BUILD-SNAPSHOT");
+ .isEqualTo("1.0.1-SNAPSHOT");
then(projectVersion("1.0.1-RC1").postReleaseSnapshotVersion())
- .isEqualTo("1.0.1-BUILD-SNAPSHOT");
+ .isEqualTo("1.0.1-SNAPSHOT");
then(projectVersion("Finchley-SR1").postReleaseSnapshotVersion())
- .isEqualTo("Finchley-BUILD-SNAPSHOT");
+ .isEqualTo("Finchley-SNAPSHOT");
}
@Test
public void should_bump_version_by_patch_version_when_bumping_snapshots_for_ga() {
- then(projectVersion("1.0.1.RELEASE").postReleaseSnapshotVersion())
- .isEqualTo("1.0.2.BUILD-SNAPSHOT");
+ then(projectVersion("1.0.1-RELEASE").postReleaseSnapshotVersion())
+ .isEqualTo("1.0.2-SNAPSHOT");
}
@Test
public void should_return_the_previous_version_for_release_train_version_when_bumping_snapshots() {
- String version = "Edgware.BUILD-SNAPSHOT";
+ String version = "Edgware-SNAPSHOT";
then(projectVersion(version).postReleaseSnapshotVersion())
- .isEqualTo("Edgware.BUILD-SNAPSHOT");
+ .isEqualTo("Edgware-SNAPSHOT");
}
@Test
public void should_return_the_previous_version_for_hyphen_release_train_version_when_bumping_snapshots() {
- String version = "Edgware-BUILD-SNAPSHOT";
+ String version = "Edgware-SNAPSHOT";
then(projectVersion(version).postReleaseSnapshotVersion())
- .isEqualTo("Edgware-BUILD-SNAPSHOT");
+ .isEqualTo("Edgware-SNAPSHOT");
}
@Test
public void should_bump_version_by_patch_version_when_bumping_releases() {
- String version = "1.0.1.RELEASE";
+ String version = "1.0.1-RELEASE";
then(projectVersion(version).postReleaseSnapshotVersion())
- .isEqualTo("1.0.2.BUILD-SNAPSHOT");
+ .isEqualTo("1.0.2-SNAPSHOT");
}
@Test
@@ -214,20 +214,20 @@ public class ProjectVersionTests {
String version = "1.0.1-RELEASE";
then(projectVersion(version).postReleaseSnapshotVersion())
- .isEqualTo("1.0.2-BUILD-SNAPSHOT");
+ .isEqualTo("1.0.2-SNAPSHOT");
}
@Test
public void should_return_the_previous_version_for_release_train_version_when_bumping_releases() {
- String version = "Edgware.RELEASE";
+ String version = "Edgware-RELEASE";
then(projectVersion(version).postReleaseSnapshotVersion())
- .isEqualTo("Edgware.BUILD-SNAPSHOT");
+ .isEqualTo("Edgware-SNAPSHOT");
}
@Test
public void should_return_true_for_snapshot_version() {
- String version = "1.0.1.BUILD-SNAPSHOT";
+ String version = "1.0.1-SNAPSHOT";
then(projectVersion(version).isSnapshot()).isTrue();
@@ -244,14 +244,14 @@ public class ProjectVersionTests {
@Test
public void should_return_false_for_milestone_version() {
- String version = "1.0.1.M1";
+ String version = "1.0.1-M1";
then(projectVersion(version).isRelease()).isFalse();
}
@Test
public void should_return_false_for_rc_version() {
- String version = "1.0.1.RC1";
+ String version = "1.0.1-RC1";
then(projectVersion(version).isRelease()).isFalse();
@@ -273,7 +273,7 @@ public class ProjectVersionTests {
@Test
public void should_return_true_for_service_release_versions() {
- String version = "1.0.1.SR1";
+ String version = "1.0.1-SR1";
then(projectVersion(version).isServiceRelease()).isTrue();
@@ -284,7 +284,7 @@ public class ProjectVersionTests {
@Test
public void should_return_true_when_checking_milestone_version_against_milestone() {
- String version = "1.0.1.M1";
+ String version = "1.0.1-M1";
then(projectVersion(version).isMilestone()).isTrue();
@@ -295,14 +295,14 @@ public class ProjectVersionTests {
@Test
public void should_return_false_when_checking_milestone_version_against_non_milestone() {
- String version = "1.0.1.RC1";
+ String version = "1.0.1-RC1";
then(projectVersion(version).isMilestone()).isFalse();
}
@Test
public void should_return_true_when_checking_rc_version_against_rc() {
- String version = "1.0.1.RC3";
+ String version = "1.0.1-RC3";
then(projectVersion(version).isRc()).isTrue();
@@ -314,30 +314,29 @@ public class ProjectVersionTests {
@Test
public void should_return_true_when_checking_ga_version_against_ga() {
then(projectVersion("1.0.1.RELEASE").isReleaseOrServiceRelease()).isTrue();
- then(projectVersion("1.0.1.SR1").isReleaseOrServiceRelease()).isTrue();
+ then(projectVersion("1.0.1-SR1").isReleaseOrServiceRelease()).isTrue();
// then(projectVersion("1.0.0").isReleaseOrServiceRelease()).isTrue();
// then(projectVersion("1.0.1").isReleaseOrServiceRelease()).isTrue();
}
@Test
public void should_return_False_when_checking_ga_version_against_non_ga() {
- then(projectVersion("1.0.1.BUILD-SNAPSHOT").isReleaseOrServiceRelease())
- .isFalse();
+ then(projectVersion("1.0.1-SNAPSHOT").isReleaseOrServiceRelease()).isFalse();
then(projectVersion("1.0.1.M4").isReleaseOrServiceRelease()).isFalse();
- then(projectVersion("1.0.1.RC4").isReleaseOrServiceRelease()).isFalse();
+ then(projectVersion("1.0.1-RC4").isReleaseOrServiceRelease()).isFalse();
}
@Test
public void should_return_false_when_checking_rc_version_against_non_rc() {
- String version = "1.0.1.M1";
+ String version = "1.0.1-M1";
then(projectVersion(version).isRc()).isFalse();
}
@Test
public void should_return_true_when_versions_are_from_same_minor() {
- String thisVersion = "1.3.1.RC3";
- String thatVersion = "1.3.2.SR3";
+ String thisVersion = "1.3.1-RC3";
+ String thatVersion = "1.3.2-SR3";
then(projectVersion(thisVersion).isSameMinor(thatVersion)).isTrue();
@@ -349,32 +348,32 @@ public class ProjectVersionTests {
@Test
public void should_return_false_when_versions_of_different_sizes() {
- String thisVersion = "1.3.1.RC3";
- String thatVersion = "1.3.RC3";
+ String thisVersion = "1.3.1-RC3";
+ String thatVersion = "1.3-RC3";
then(projectVersion(thisVersion).isSameMinor(thatVersion)).isFalse();
}
@Test
public void should_return_false_when_versions_not_of_same_minor() {
- String thisVersion = "1.3.1.RC3";
- String thatVersion = "1.4.2.RC3";
+ String thisVersion = "1.3.1-RC3";
+ String thatVersion = "1.4.2-RC3";
then(projectVersion(thisVersion).isSameMinor(thatVersion)).isFalse();
}
@Test
public void should_return_equal_when_versions_are_the_same() {
- String thisVersion = "1.3.1.SR3";
- String thatVersion = "1.3.1.SR3";
+ String thisVersion = "1.3.1-SR3";
+ String thatVersion = "1.3.1-SR3";
then(projectVersion(thisVersion).compareTo(projectVersion(thatVersion))).isZero();
}
@Test
public void should_return_greater_when_versions_this_version_is_greater_than_the_other() {
- String thisVersion = "1.3.2.SR3";
- String thatVersion = "1.3.1.SR3";
+ String thisVersion = "1.3.2-SR3";
+ String thatVersion = "1.3.1-SR3";
then(projectVersion(thisVersion).compareTo(projectVersion(thatVersion)))
.isPositive();
@@ -382,8 +381,8 @@ public class ProjectVersionTests {
@Test
public void should_return_lower_when_versions_this_version_is_lower_than_the_other() {
- String thisVersion = "1.3.0.RC3";
- String thatVersion = "1.3.1.RC3";
+ String thisVersion = "1.3.0-RC3";
+ String thatVersion = "1.3.1-RC3";
then(projectVersion(thisVersion).compareTo(projectVersion(thatVersion)))
.isNegative();
@@ -393,220 +392,299 @@ public class ProjectVersionTests {
public void should_compare_builds_in_terms_of_maturity_for_projects() {
String thisVersion = "1.3.2.RELEASE";
- then(projectVersion(thisVersion)
- .isMoreMature(projectVersion("1.3.1.BUILD-SNAPSHOT"))).isTrue();
- then(projectVersion(thisVersion).isMoreMature(projectVersion("1.3.1.M1")))
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("1.3.1-SNAPSHOT")))
.isTrue();
- then(projectVersion(thisVersion).isMoreMature(projectVersion("1.3.1.RC1")))
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("1.3.1-M1")))
+ .isTrue();
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("1.3.1-RC1")))
.isTrue();
then(projectVersion(thisVersion).isMoreMature(projectVersion("1.3.1.RELEASE")))
.isTrue();
then(projectVersion(thisVersion).isMoreMature(projectVersion("1.3.3.RELEASE")))
.isFalse();
- then(projectVersion(thisVersion)
- .isMoreMature(projectVersion("1.3.3.BUILD-SNAPSHOT"))).isTrue();
- then(projectVersion(thisVersion).isMoreMature(projectVersion("1.3.3.M1")))
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("1.3.3-SNAPSHOT")))
.isTrue();
- then(projectVersion(thisVersion).isMoreMature(projectVersion("1.3.3.RC1")))
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("1.3.3-M1")))
+ .isTrue();
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("1.3.3-RC1")))
.isTrue();
}
@Test
public void should_compare_builds_in_terms_of_maturity_for_trains() {
- String thisVersion = "Hoxton.SR1";
+ String thisVersion = "Hoxton-SR1";
- then(projectVersion(thisVersion)
- .isMoreMature(projectVersion("Hoxton.BUILD-SNAPSHOT"))).isTrue();
- then(projectVersion(thisVersion).isMoreMature(projectVersion("Hoxton.M1")))
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("Hoxton-SNAPSHOT")))
.isTrue();
- then(projectVersion(thisVersion).isMoreMature(projectVersion("Hoxton.RC1")))
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("Hoxton-M1")))
+ .isTrue();
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("Hoxton-RC1")))
.isTrue();
then(projectVersion(thisVersion).isMoreMature(projectVersion("Hoxton.RELEASE")))
.isTrue();
then(projectVersion(thisVersion)
- .isMoreMature(projectVersion("Iexample.BUILD-SNAPSHOT"))).isTrue();
- then(projectVersion(thisVersion).isMoreMature(projectVersion("Iexample.M1")))
+ .isMoreMature(projectVersion("Iexample-SNAPSHOT"))).isTrue();
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("Iexample-M1")))
.isTrue();
- then(projectVersion(thisVersion).isMoreMature(projectVersion("Iexample.RC1")))
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("Iexample-RC1")))
.isTrue();
then(projectVersion(thisVersion).isMoreMature(projectVersion("Iexample.RELEASE")))
.isFalse();
- then(projectVersion(thisVersion).isMoreMature(projectVersion("Iexample.SR1")))
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("Iexample-SR1")))
.isFalse();
- thisVersion = "Hoxton.BUILD-SNAPSHOT";
+ thisVersion = "Hoxton-SNAPSHOT";
- then(projectVersion(thisVersion)
- .isMoreMature(projectVersion("Hoxton.BUILD-SNAPSHOT"))).isFalse();
- then(projectVersion(thisVersion).isMoreMature(projectVersion("Hoxton.M1")))
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("Hoxton-SNAPSHOT")))
.isFalse();
- then(projectVersion(thisVersion).isMoreMature(projectVersion("Hoxton.RC1")))
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("Hoxton-M1")))
+ .isFalse();
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("Hoxton-RC1")))
.isFalse();
then(projectVersion(thisVersion).isMoreMature(projectVersion("Hoxton.RELEASE")))
.isFalse();
then(projectVersion(thisVersion)
- .isMoreMature(projectVersion("Iexample.BUILD-SNAPSHOT"))).isFalse();
- then(projectVersion(thisVersion).isMoreMature(projectVersion("Iexample.M1")))
+ .isMoreMature(projectVersion("Iexample-SNAPSHOT"))).isFalse();
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("Iexample-M1")))
.isFalse();
- then(projectVersion(thisVersion).isMoreMature(projectVersion("Iexample.RC1")))
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("Iexample-RC1")))
.isFalse();
then(projectVersion(thisVersion).isMoreMature(projectVersion("Iexample.RELEASE")))
.isFalse();
- then(projectVersion(thisVersion).isMoreMature(projectVersion("Iexample.SR1")))
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("Iexample-SR1")))
.isFalse();
thisVersion = "1.0.1.RELEASE";
- then(projectVersion(thisVersion)
- .isMoreMature(projectVersion("1.0.1.BUILD-SNAPSHOT"))).isTrue();
- then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.1.M1")))
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.1-SNAPSHOT")))
.isTrue();
- then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.1.RC1")))
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.1-M1")))
+ .isTrue();
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.1-RC1")))
.isTrue();
then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.1.RELEASE")))
.isFalse();
- then(projectVersion(thisVersion)
- .isMoreMature(projectVersion("1.0.2.BUILD-SNAPSHOT"))).isTrue();
- then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.2.M1")))
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.2-SNAPSHOT")))
.isTrue();
- then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.2.RC1")))
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.2-M1")))
+ .isTrue();
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.2-RC1")))
.isTrue();
then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.2.RELEASE")))
.isFalse();
- then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.2.SR1")))
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.2-SR1")))
.isFalse();
- thisVersion = "1.0.1.BUILD-SNAPSHOT";
+ thisVersion = "1.0.1-SNAPSHOT";
- then(projectVersion(thisVersion)
- .isMoreMature(projectVersion("1.0.1.BUILD-SNAPSHOT"))).isFalse();
- then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.1.M1")))
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.1-SNAPSHOT")))
.isFalse();
- then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.1.RC1")))
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.1-M1")))
+ .isFalse();
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.1-RC1")))
.isFalse();
then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.1.RELEASE")))
.isFalse();
- then(projectVersion(thisVersion)
- .isMoreMature(projectVersion("1.0.2.BUILD-SNAPSHOT"))).isFalse();
- then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.2.M1")))
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.2-SNAPSHOT")))
.isFalse();
- then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.2.RC1")))
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.2-M1")))
+ .isFalse();
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.2-RC1")))
.isFalse();
then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.2.RELEASE")))
.isFalse();
- then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.2.SR1")))
+ then(projectVersion(thisVersion).isMoreMature(projectVersion("1.0.2-SR1")))
.isFalse();
}
@Test
public void should_return_empty_group_id_when_it_is_missing() {
- ProjectVersion projectVersion = projectVersion("1.0.0.RC1");
+ ProjectVersion projectVersion = projectVersion("1.0.0-RC1");
then(projectVersion.groupId()).isEmpty();
}
@Test
public void should_return_true_when_release_train_names_are_the_same() {
- String thisVersion = "Finchley.SR1";
- String thatVersion = "Finchley.SR2";
+ String thisVersion = "Finchley-SR1";
+ String thatVersion = "Finchley-SR2";
then(projectVersion(thisVersion).isSameReleaseTrainName(thatVersion)).isTrue();
}
@Test
public void should_return_true_when_sr_has_two_digits() {
- String thisVersion = "Finchley.SR1";
- String thatVersion = "Finchley.SR10";
+ String thisVersion = "Finchley-SR1";
+ String thatVersion = "Finchley-SR10";
- then(projectVersion(thatVersion).compareToReleaseTrainName(thisVersion))
- .isPositive();
+ then(projectVersion(thatVersion).compareToReleaseTrain(thisVersion)).isPositive();
}
@Test
public void should_return_false_when_release_train_name_are_different() {
- String thisVersion = "Finchley.SR1";
- String thatVersion = "Greenwich.SR1";
+ String thisVersion = "Finchley-SR1";
+ String thatVersion = "Greenwich-SR1";
then(projectVersion(thisVersion).isSameReleaseTrainName(thatVersion)).isFalse();
}
@Test
public void should_return_positive_when_release_train_is_greater_than_the_other_one() {
- String thisVersion = "Finchley.SR2";
- String thatVersion = "Finchley.SR1";
+ String thisVersion = "Finchley-SR2";
+ String thatVersion = "Finchley-SR1";
- then(projectVersion(thisVersion).compareToReleaseTrainName(thatVersion))
- .isPositive();
+ then(projectVersion(thisVersion).compareToReleaseTrain(thatVersion)).isPositive();
- thisVersion = "Greenwich.SR1";
- thatVersion = "Finchley.SR2";
+ thisVersion = "Greenwich-SR1";
+ thatVersion = "Finchley-SR2";
- then(projectVersion(thisVersion).compareToReleaseTrainName(thatVersion))
- .isPositive();
+ then(projectVersion(thisVersion).compareToReleaseTrain(thatVersion)).isPositive();
}
@Test
public void should_return_0_when_release_train_is_equal_than_the_other_one() {
- String thisVersion = "Finchley.SR1";
- String thatVersion = "Finchley.SR1";
+ String thisVersion = "Finchley-SR1";
+ String thatVersion = "Finchley-SR1";
- then(projectVersion(thisVersion).compareToReleaseTrainName(thatVersion)).isZero();
+ then(projectVersion(thisVersion).compareToReleaseTrain(thatVersion)).isZero();
}
@Test
public void should_return_minus_1_when_release_train_is_smaller_than_the_other_one() {
- String thisVersion = "Finchley.SR1";
- String thatVersion = "Finchley.SR2";
+ String thisVersion = "Finchley-SR1";
+ String thatVersion = "Finchley-SR2";
- then(projectVersion(thisVersion).compareToReleaseTrainName(thatVersion))
- .isNegative();
+ then(projectVersion(thisVersion).compareToReleaseTrain(thatVersion)).isNegative();
- thisVersion = "Finchley.SR2";
- thatVersion = "Greenwich.SR1";
+ thisVersion = "Finchley-SR2";
+ thatVersion = "Greenwich-SR1";
- then(projectVersion(thisVersion).compareToReleaseTrainName(thatVersion))
- .isNegative();
+ then(projectVersion(thisVersion).compareToReleaseTrain(thatVersion)).isNegative();
}
@Test
public void should_return_minus_1_when_this_train_is_empty() {
String thisVersion = "";
- String thatVersion = "Finchley.SR2";
+ String thatVersion = "Finchley-SR2";
- then(projectVersion(thisVersion).compareToReleaseTrainName(thatVersion))
- .isNegative();
+ then(projectVersion(thisVersion).compareToReleaseTrain(thatVersion)).isNegative();
thisVersion = "";
thatVersion = "";
- then(projectVersion(thisVersion).compareToReleaseTrainName(thatVersion)).isZero();
+ then(projectVersion(thisVersion).compareToReleaseTrain(thatVersion)).isZero();
}
@Test
public void should_return_plus_1_when_that_train_is_empty() {
- String thisVersion = "Finchley.SR1";
+ String thisVersion = "Finchley-SR1";
String thatVersion = "";
- then(projectVersion(thisVersion).compareToReleaseTrainName(thatVersion))
- .isPositive();
+ then(projectVersion(thisVersion).compareToReleaseTrain(thatVersion)).isPositive();
+ }
+
+ @Test
+ public void should_return_true_when_calver_release_train_names_are_the_same() {
+ String thisVersion = "2020.0.1";
+ String thatVersion = "2020.0.2";
+
+ then(projectVersion(thisVersion).isSameReleaseTrainName(thatVersion)).isTrue();
+ }
+
+ @Test
+ public void should_return_true_when_calver_sr_has_two_digits() {
+ String thisVersion = "2020.0.1";
+ String thatVersion = "2020.0.10";
+
+ then(projectVersion(thatVersion).compareToReleaseTrain(thisVersion)).isPositive();
+ }
+
+ @Test
+ public void should_return_false_when_calver_release_train_name_are_different() {
+ String thisVersion = "2020.0.1";
+ String thatVersion = "2020.1.0";
+
+ then(projectVersion(thisVersion).isSameReleaseTrainName(thatVersion)).isFalse();
+ }
+
+ @Test
+ public void should_return_positive_when_calver_release_train_is_greater_than_the_other_one() {
+ String thisVersion = "2020.0.2";
+ String thatVersion = "2020.0.1";
+
+ then(projectVersion(thisVersion).compareToReleaseTrain(thatVersion)).isPositive();
+
+ thisVersion = "2020.1.1";
+ thatVersion = "2020.0.2";
+
+ then(projectVersion(thisVersion).compareToReleaseTrain(thatVersion)).isPositive();
+ }
+
+ @Test
+ public void should_return_0_when_calver_release_train_is_equal_than_the_other_one() {
+ String thisVersion = "2020.0.1";
+ String thatVersion = "2020.0.1";
+
+ then(projectVersion(thisVersion).compareToReleaseTrain(thatVersion)).isZero();
+ }
+
+ @Test
+ public void should_return_minus_1_when_calver_release_train_is_smaller_than_the_other_one() {
+ String thisVersion = "2020.0.1";
+ String thatVersion = "2020.0.2";
+
+ then(projectVersion(thisVersion).compareToReleaseTrain(thatVersion)).isNegative();
+
+ thisVersion = "2020.0.2";
+ thatVersion = "2020.1.1";
+
+ then(projectVersion(thisVersion).compareToReleaseTrain(thatVersion)).isNegative();
+ }
+
+ @Test
+ public void should_return_minus_1_when_this_calver_train_is_empty() {
+ String thisVersion = "";
+ String thatVersion = "2020.1.1";
+
+ then(projectVersion(thisVersion).compareToReleaseTrain(thatVersion)).isNegative();
+
+ thisVersion = "";
+ thatVersion = "";
+
+ then(projectVersion(thisVersion).compareToReleaseTrain(thatVersion)).isZero();
+ }
+
+ @Test
+ public void should_return_plus_1_when_that_calver_train_is_empty() {
+ String thisVersion = "2020.1.1";
+ String thatVersion = "";
+
+ then(projectVersion(thisVersion).compareToReleaseTrain(thatVersion)).isPositive();
+ }
+
+ @Test
+ public void should_return_greater_than_when_comparing_calver_to_non_calver() {
+ String thisVersion = "2020.1.1";
+ String thatVersion = "Greenwich-SR5";
+
+ then(projectVersion(thisVersion).compareToReleaseTrain(thatVersion)).isPositive();
}
@Test
public void should_return_no_unacceptable_patterns_for_a_snapshot_version() {
- then(projectVersion("1.0.0.BUILD-SNAPSHOT").unacceptableVersionPatterns())
- .isEmpty();
+ then(projectVersion("1.0.0-SNAPSHOT").unacceptableVersionPatterns()).isEmpty();
then(projectVersion("1.0.0.SNAPSHOT").unacceptableVersionPatterns()).isEmpty();
then(projectVersion("1.0.0-SNAPSHOT").unacceptableVersionPatterns()).isEmpty();
}
@Test
public void should_return_snapshot_unacceptable_patterns_for_a_milestone_or_rc_version() {
- List milestonePatterns = projectVersion("1.0.0.M1")
+ List milestonePatterns = projectVersion("1.0.0-M1")
.unacceptableVersionPatterns();
then(milestonePatterns).isNotEmpty();
then(milestonePatterns.get(0).pattern()).contains("SNAPSHOT");
- List rcPatterns = projectVersion("1.0.0.RC1")
+ List rcPatterns = projectVersion("1.0.0-RC1")
.unacceptableVersionPatterns();
then(rcPatterns).isNotEmpty();
then(rcPatterns.get(0).pattern()).contains("SNAPSHOT");
@@ -634,7 +712,7 @@ public class ProjectVersionTests {
gaPatterns = projectVersion("1.0.0-RELEASE").unacceptableVersionPatterns();
thenPatternsForSnapshotMilestoneAndReleaseCandidateArePresent(gaPatterns);
- List srPatterns = projectVersion("1.0.0.SR1")
+ List srPatterns = projectVersion("1.0.0-SR1")
.unacceptableVersionPatterns();
thenPatternsForSnapshotMilestoneAndReleaseCandidateArePresent(srPatterns);
@@ -656,7 +734,7 @@ public class ProjectVersionTests {
@Test
public void should_return_empty_when_tag_name_is_non_ga() {
- then(projectVersion("1.0.0.BUILD-SNAPSHOT").releaseTagName()).isEmpty();
+ then(projectVersion("1.0.0-SNAPSHOT").releaseTagName()).isEmpty();
}
@Test
@@ -729,8 +807,7 @@ public class ProjectVersionTests {
then(unknownTypeOfVersion.get(1).pattern()).contains("M[0-9]");
then(unknownTypeOfVersion.get(2).pattern()).contains("RC");
- then(unknownTypeOfVersion.get(0).matcher("SomeName-BUILD-SNAPSHOT").matches())
- .isTrue();
+ then(unknownTypeOfVersion.get(0).matcher("SomeName-SNAPSHOT").matches()).isTrue();
then(unknownTypeOfVersion.get(0).matcher("SomeName.BUILD-SNAPSHOT").matches())
.isTrue();
diff --git a/releaser-core/src/test/java/releaser/internal/buildsystem/ProjectsTests.java b/releaser-core/src/test/java/releaser/internal/buildsystem/ProjectsTests.java
index e17c1b34..0b2441fd 100644
--- a/releaser-core/src/test/java/releaser/internal/buildsystem/ProjectsTests.java
+++ b/releaser-core/src/test/java/releaser/internal/buildsystem/ProjectsTests.java
@@ -78,9 +78,9 @@ public class ProjectsTests {
@Test
public void should_create_project_with_bumped_original_version_and_original_parent_versions() {
Set projectVersions = new HashSet<>();
- ProjectVersion build = new ProjectVersion("spring-cloud-build", "1.0.0.RELEASE");
+ ProjectVersion build = new ProjectVersion("spring-cloud-build", "1.0.0-RELEASE");
projectVersions.add(build);
- ProjectVersion boot = new ProjectVersion("spring-boot-starter", "2.0.0.RELEASE");
+ ProjectVersion boot = new ProjectVersion("spring-boot-starter", "2.0.0-RELEASE");
projectVersions.add(boot);
ProjectVersion bootDeps = new ProjectVersion("spring-boot-dependencies",
"2.0.0.RELEASE");
@@ -94,9 +94,9 @@ public class ProjectsTests {
projects);
then(forRollback.forName("spring-cloud-build").version)
- .isEqualTo("1.0.1.BUILD-SNAPSHOT");
+ .isEqualTo("1.0.1-SNAPSHOT");
then(forRollback.forName("spring-boot-starter").version)
- .isEqualTo("2.0.0.RELEASE");
+ .isEqualTo("2.0.0-RELEASE");
then(forRollback.forName("spring-boot-dependencies").version)
.isEqualTo("2.0.0.RELEASE");
then(forRollback.forName("spring-cloud-starter-foo").version)
@@ -166,12 +166,12 @@ public class ProjectsTests {
then(bumped.forName("spring-boot-dependencies").version)
.isEqualTo("2.0.0.RELEASE");
then(bumped.forName("spring-boot-starter").version).isEqualTo("2.0.0.RELEASE");
- then(bumped.forName("foo").version).isEqualTo("1.0.1.BUILD-SNAPSHOT");
- then(bumped.forName("bar").version).isEqualTo("1.0.1.BUILD-SNAPSHOT");
+ then(bumped.forName("foo").version).isEqualTo("1.0.1.SNAPSHOT");
+ then(bumped.forName("bar").version).isEqualTo("1.0.1.SNAPSHOT");
then(bumped.forName("baz").version).isEqualTo("1.0.2.BUILD-SNAPSHOT");
- then(bumped.forName("foo2").version).isEqualTo("1.0.1.BUILD-SNAPSHOT");
+ then(bumped.forName("foo2").version).isEqualTo("1.0.1.SNAPSHOT");
then(bumped.forName("foo3").version).isEqualTo("Finchley.BUILD-SNAPSHOT");
- then(bumped.forName("foo4").version).isEqualTo("Finchley.BUILD-SNAPSHOT");
+ then(bumped.forName("foo4").version).isEqualTo("Finchley.SNAPSHOT");
}
@Test
diff --git a/releaser-core/src/test/java/releaser/internal/postrelease/PostReleaseActionsTests.java b/releaser-core/src/test/java/releaser/internal/postrelease/PostReleaseActionsTests.java
index 1c8cbb46..5374f995 100644
--- a/releaser-core/src/test/java/releaser/internal/postrelease/PostReleaseActionsTests.java
+++ b/releaser-core/src/test/java/releaser/internal/postrelease/PostReleaseActionsTests.java
@@ -285,7 +285,7 @@ public class PostReleaseActionsTests {
Git git = GitTestUtils.openGitProject(clonedFile);
BDDAssertions
.then(pomWithCloud.getProperties().getProperty("spring-cloud.version"))
- .isEqualTo("Finchley.BUILD-SNAPSHOT");
+ .isEqualTo("Finchley.SNAPSHOT");
BDDAssertions.then(pomWithCloud.getParent().getVersion())
.isEqualTo("2.0.4.RELEASE");
Iterator iterator = git.log().call().iterator();
diff --git a/releaser-spring/pom.xml b/releaser-spring/pom.xml
index ffb812a3..e69f4558 100644
--- a/releaser-spring/pom.xml
+++ b/releaser-spring/pom.xml
@@ -10,7 +10,7 @@
org.springframework.cloud.internal
releaser-parent
- 1.0.0.BUILD-SNAPSHOT
+ 2.0.0-SNAPSHOT
..
diff --git a/releaser-test/pom.xml b/releaser-test/pom.xml
index 822ddef0..0de13123 100644
--- a/releaser-test/pom.xml
+++ b/releaser-test/pom.xml
@@ -10,7 +10,7 @@
org.springframework.cloud.internal
releaser-parent
- 1.0.0.BUILD-SNAPSHOT
+ 2.0.0-SNAPSHOT
..
diff --git a/spring-cloud-info/pom.xml b/spring-cloud-info/pom.xml
index 2255f9fe..1bbd6e6f 100644
--- a/spring-cloud-info/pom.xml
+++ b/spring-cloud-info/pom.xml
@@ -5,7 +5,7 @@
releaser-parent
org.springframework.cloud.internal
- 1.0.0.BUILD-SNAPSHOT
+ 2.0.0-SNAPSHOT
4.0.0