Skip to content

Latest commit

 

History

History
53 lines (39 loc) · 1.33 KB

README.md

File metadata and controls

53 lines (39 loc) · 1.33 KB

io.github.serpro69:semver.kt-spec:$version

Maven Central Sonatype Nexus (Snapshots)

Intro

A kotlin implementation of the semver spec.

Usage

Adding a dependency

gradle:

implementation("io.github.serpro69:semver.kt-spec:$version")

maven:

<dependency>
    <groupId>io.github.serpro69</groupId>
    <artifactId>semver.kt-spec</artifactId>
    <version>${version}</version>
</dependency>

Using Semver class

val semver = Semver("1.2.3")

// Incrementing a version
semver.incrementMajor() // 2.0.0
semver.incrementMinor() // 2.1.0
semver.incrementPatch() // 2.1.1
Semver("1.2.3-rc.4").incrementPreRelease() // 1.2.3-rc.5

// Comparing versions
println(semver > "0.0.1".toSemver()) // true

// Accessing version properties
with(Semver("1.2.3-rc.4+build.567")) {
    this.major // 1
    this.minor // 2
    this.patch // 3
    this.normalVersion // 1.2.3
    this.preRelease // rc.4
    this.buildMetadata // build.567
}