Fix snapshot version rollover for new release schema
Not sure it will handle all cases, but at least for now anything that is 3.1.x will properly be bumped to 3.1.1-SNAPSHOT
This commit is contained in:
@@ -206,6 +206,27 @@ public class ProjectVersion implements Comparable<ProjectVersion>, Serializable
|
||||
int numberOfHyphens = splitByHyphens - 1;
|
||||
int indexOfFirstHyphen = version.indexOf("-");
|
||||
boolean buildSnapshot = version.endsWith("BUILD-SNAPSHOT");
|
||||
|
||||
String[] splitVersion = StringUtils.delimitedListToStringArray(version, ".");
|
||||
boolean newVersionSchema = splitVersion.length == 3;
|
||||
for (int i = 0; i < splitVersion.length && newVersionSchema; i++) {
|
||||
try {
|
||||
int v = Integer.parseInt(splitVersion[i]);
|
||||
if (i == 0) {
|
||||
newVersionSchema = v == 3;
|
||||
}
|
||||
else if (i == 1) {
|
||||
newVersionSchema = v >= 1;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
newVersionSchema = false;
|
||||
}
|
||||
}
|
||||
if (newVersionSchema) {
|
||||
SplitVersion v = SplitVersion.hyphen(splitVersion);
|
||||
return v;
|
||||
}
|
||||
if (numberOfHyphens == 1 && !buildSnapshot
|
||||
|| (numberOfHyphens > 1 && buildSnapshot)) {
|
||||
// Dysprosium or 1.0.0
|
||||
|
||||
@@ -221,6 +221,10 @@ public class ProjectVersionTests {
|
||||
|
||||
then(projectVersion(version).postReleaseSnapshotVersion())
|
||||
.isEqualTo("1.0.2-SNAPSHOT");
|
||||
|
||||
version = "3.1.0";
|
||||
then(projectVersion(version).postReleaseSnapshotVersion())
|
||||
.isEqualTo("3.1.1-SNAPSHOT");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -286,9 +290,9 @@ public class ProjectVersionTests {
|
||||
String version = "1.0.1-SR1";
|
||||
|
||||
then(projectVersion(version).isServiceRelease()).isTrue();
|
||||
|
||||
//
|
||||
String newServiceReleaseVersion = "2020.0.1";
|
||||
|
||||
//
|
||||
then(projectVersion(newServiceReleaseVersion).isServiceRelease()).isTrue();
|
||||
|
||||
newServiceReleaseVersion = "3.0.1";
|
||||
|
||||
Reference in New Issue
Block a user