Semantic Versioning implementation in Kotlin.
Semver represents the versioning system specified in Semantic Versioning Specification.
Semver requires no external dependencies. You can install the library via:
// build.gradle
repositories {
jcenter()
}
dependencies {
implementation 'com.github.glwithu06.semver:semver:x.y.z'
}// build.gradle
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.glwithu06:semver.kt:x.y.z'
}You can create a Semver instance like the following:
val version = Semver(major = 1, minor = 23, patch = 45, prereleaseIdentifiers = listOf("rc", "1"), buildMetadataIdentifiers = listOf("B001"))
minor, patch are optional parameters and set to "0" by default.
prereleaseIdentifiers, buildMetadataIdentifiers are optional parameters and set to empty lists by default.
You can create Semver from String:
val version = Semver("1.23.45-rc.1+B001")
or from Numeric:
val version = Semver(1.23)val version = Semver(10)If the given argument has an invalid format, it throws a IllegalArgumentException.
Semver class implements Comparable interface and overrides equals(), so their instances can be compared using the default operators including < , <= , > ,>= ,== , !=.
The comparison rules are specified in Semantic Versioning Specification.
Pull requests and bug reports are welcomed!
Feel free to make a pull request.