Skip to content
Semantic versioning framework in Kotlin
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
gradle/wrapper Add gradle-wrapper.jar Mar 9, 2019
lint Add detekt Mar 8, 2019
src Add test cases. Mar 21, 2019
.gitignore Import .gitignore Mar 5, 2019
.travis.yml
LICENSE Initial commit Jan 20, 2019
README.md Update README.md Mar 19, 2019
build.gradle.kts Bump version to 1.0.1 Mar 21, 2019
gradlew Initialize gradle Mar 5, 2019
gradlew.bat Initialize gradle Mar 5, 2019
settings.gradle.kts Implement tests Mar 6, 2019

README.md

Kotlin Build Status Codecov

Semantic Versioning

Semantic Versioning implementation in Kotlin. Semver represents the versioning system specified in Semantic Versioning Specification.

Installation

Semver requires no external dependencies. You can install the library via:

Gradle

// build.gradle
repositories {
    jcenter()
}
dependencies {
    implementation 'com.github.glwithu06.semver:semver:x.y.z'
}

JitPack

// build.gradle
repositories {
    maven { url 'https://jitpack.io' }
}
dependencies {
    implementation 'com.github.glwithu06:semver.kt:x.y.z'
}

Usage

Create

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.

Parse

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.

Compare

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.

Contribution

Pull requests and bug reports are welcomed!

Feel free to make a pull request.

You can’t perform that action at this time.