mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-18 07:52:14 +01:00
Now using semantic versioning
This commit is contained in:
parent
d8ef27887e
commit
0489585c3e
BIN
arduino-core/lib/java-semver-0.8.0.jar
Normal file
BIN
arduino-core/lib/java-semver-0.8.0.jar
Normal file
Binary file not shown.
0
arduino-core/lib/java-semver.LICENSE.MIT.txt
Normal file
0
arduino-core/lib/java-semver.LICENSE.MIT.txt
Normal file
@ -28,6 +28,8 @@
|
||||
*/
|
||||
package cc.arduino.packages.contributions;
|
||||
|
||||
import com.github.zafarkhaja.semver.Version;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
public class VersionComparator implements Comparator<String> {
|
||||
@ -45,8 +47,23 @@ public class VersionComparator implements Comparator<String> {
|
||||
if (b == null)
|
||||
return 1;
|
||||
|
||||
// TODO: do a proper version compare. Look also http://semver.org/
|
||||
return a.compareTo(b);
|
||||
Version versionA = valueOf(a);
|
||||
Version versionB = valueOf(b);
|
||||
|
||||
return versionA.compareTo(versionB);
|
||||
}
|
||||
|
||||
private Version valueOf(String ver) {
|
||||
String[] verParts = ver.split("\\.");
|
||||
if (verParts.length < 3) {
|
||||
if (verParts.length == 2) {
|
||||
return Version.forIntegers(Integer.valueOf(verParts[0]), Integer.valueOf(verParts[1]));
|
||||
} else {
|
||||
return Version.forIntegers(Integer.valueOf(verParts[0]));
|
||||
}
|
||||
} else {
|
||||
return Version.valueOf(ver);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user