Skip to content

Commit fef2cab

Browse files
committed
Handle Grails 5.0.0-SNAPSHOT string
Extended GrailsVersion and Snapshot classes to property handle string "5.0.0-SNAPSHOT" alongwith "5.0.0.BUILD-SNAPSHOT". Fixes #1463
1 parent ed6d474 commit fef2cab

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/core/grailsversion/GrailsVersion.groovy

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,17 @@ class GrailsVersion implements Comparable<GrailsVersion> {
5050
String[] parts = version.split("\\.")
5151
if (parts.length >= 3) {
5252
this.versionText = version
53+
this.major = parts[0].toInteger()
54+
this.minor = parts[1].toInteger()
5355
if (parts.length > 3) {
5456
this.snapshot = new Snapshot(parts[3])
57+
} else if (parts[2].contains('-')) {
58+
String[] subParts = parts[2].split("-")
59+
this.patch = subParts.first() as int
60+
this.snapshot = new Snapshot(subParts[1..-1].join("-"))
61+
} else {
62+
this.patch = parts[2].toInteger()
5563
}
56-
this.major = parts[0].toInteger()
57-
this.minor = parts[1].toInteger()
58-
this.patch = parts[2].toInteger()
5964
} else {
6065
throw new IllegalArgumentException("GrailsVersion only supports comparison of versions with 3 or 4 parts")
6166
}

grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/core/grailsversion/Snapshot.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import groovy.transform.EqualsAndHashCode
1212
@EqualsAndHashCode(includes = ['text'])
1313
class Snapshot implements Comparable<Snapshot> {
1414

15-
private static final String BUILD_SNAPSHOT = "BUILD-SNAPSHOT"
15+
private static final String SNAPSHOT = "SNAPSHOT"
1616
private static final String RC = "RC"
1717
private static final String MILESTONE = "M"
1818

@@ -32,7 +32,7 @@ class Snapshot implements Comparable<Snapshot> {
3232
}
3333

3434
boolean isBuildSnapshot() {
35-
text == BUILD_SNAPSHOT
35+
text.endsWith(SNAPSHOT)
3636
}
3737

3838
boolean isReleaseCandidate() {

0 commit comments

Comments
 (0)