Skip to content

Commit 2849a56

Browse files
[release/v7.x] refactor(version): adjust to new semver 0.10.2 release (#142)
- after zafarkhaja went MIA after 2015, AntiLaby took over and released 0.10.0 in 2019 - zafarkhaja came back now and published a conflicting 0.10.0 release with breaking changes - getMajorVersion, getMinorVersion, getPatchVersion methods were removed - fixed by using new majorVersion, minorVersion, patchVersion methods - also switched to suggested alternatives for methods deprecated with 0.10.0 - forIntegers -> of - valueOf -> parse - getPreReleaseVersion -> preReleaseVersion - increment[Major|Minor|Patch]Version -> next[Major|Minor|Patch]Version Co-authored-by: Josephine Rueckert <jd.rueckert@googlemail.com>
1 parent eae3f88 commit 2849a56

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

gestalt-module/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies {
1212
implementation 'org.apache.commons:commons-vfs2:2.2'
1313
implementation "org.slf4j:slf4j-api:$slf4j_version"
1414
implementation "com.android.support:support-annotations:$android_annotation_version"
15-
api "com.github.zafarkhaja:java-semver:0.10.0"
15+
api "com.github.zafarkhaja:java-semver:0.10.2"
1616

1717
testImplementation project(":testpack:testpack-api")
1818
testImplementation "ch.qos.logback:logback-classic:$logback_version"

gestalt-module/src/main/java/org/terasology/gestalt/naming/Version.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public Version(int major, int minor, int patch, boolean snapshot) {
4848
}
4949

5050

51-
final com.github.zafarkhaja.semver.Version baseVersion = com.github.zafarkhaja.semver.Version.forIntegers(major, minor, patch);
51+
final com.github.zafarkhaja.semver.Version baseVersion = com.github.zafarkhaja.semver.Version.of(major, minor, patch);
5252
this.semver = snapshot ? baseVersion.setPreReleaseVersion(SNAPSHOT) : baseVersion;
5353
}
5454

@@ -58,7 +58,7 @@ public Version(int major, int minor, int patch, boolean snapshot) {
5858
*/
5959
public Version(String version) {
6060
try {
61-
this.semver = com.github.zafarkhaja.semver.Version.valueOf(version);
61+
this.semver = com.github.zafarkhaja.semver.Version.parse(version);
6262
} catch (ParseException e) {
6363
throw new VersionParseException("Invalid version '" + version + "' - must be of the form MAJOR.minor.patch");
6464
}
@@ -74,38 +74,38 @@ private Version(com.github.zafarkhaja.semver.Version semver) {
7474
}
7575

7676
public int getMajor() {
77-
return semver.getMajorVersion();
77+
return (int) semver.majorVersion();
7878
}
7979

8080
public int getMinor() {
81-
return semver.getMinorVersion();
81+
return (int) semver.minorVersion();
8282
}
8383

8484
public int getPatch() {
85-
return semver.getPatchVersion();
85+
return (int) semver.patchVersion();
8686
}
8787

8888
/**
8989
* @return Whether this version is a snapshot (work in progress)
9090
*/
9191
public boolean isSnapshot() {
92-
return !semver.getPreReleaseVersion().isEmpty();
92+
return !semver.preReleaseVersion().isEmpty();
9393
}
9494

9595
public Version getSnapshot() {
9696
return new Version(semver.setPreReleaseVersion(SNAPSHOT));
9797
}
9898

9999
public Version getNextMajorVersion() {
100-
return new Version(semver.incrementMajorVersion());
100+
return new Version(semver.nextMajorVersion());
101101
}
102102

103103
public Version getNextMinorVersion() {
104-
return new Version(semver.incrementMinorVersion());
104+
return new Version(semver.nextMinorVersion());
105105
}
106106

107107
public Version getNextPatchVersion() {
108-
return new Version(semver.incrementPatchVersion());
108+
return new Version(semver.nextPatchVersion());
109109
}
110110

111111
/**

0 commit comments

Comments
 (0)