
Facilitates semantic versioning management through building, comparing, and incrementing version numbers. Supports flexible version creation using string or integer parameters, and allows copying with modifications.
A Kotlin Multiplatform library to work with semantic versioning
implementation("com.javiersc.semver:semver-core:$version")A Version must match the following format:
<major>.<minor>.<patch?>-<stage?.name>.<stage?.num>
patchandstagecan be null.
There are 3 options to build a Version.
Version("1.0.0")
Version("1.0.0-alpha.1")
Version("12.23.34-alpha.45")Version("1.0.0", "alpha.1")
Version("12.23.34", "alpha.45")Version(1, 0, 0)
Version(1, 0, 0, "alpha", 1)
Version(12, 23, 34, "alpha", 45)Version("1.0.1") > Version("1.0.0") // true
Version("1.0.1") < Version("1.0.0") // false
Version("1.0.0") == Version("1.0.0") // trueVersion("2.4.6-alpha.1").inc(Version.Increase.Patch) // 2.4.7 (stage and num are removed)
Version("2.4.6").inc(Version.Increase.Patch) // 2.4.7
Version("2.4.6").inc(Version.Increase.Minor) // 2.5.0 (patch is reset to 0)
Version("2.4.6").inc(Version.Increase.Major) // 3.0.0 (minor and patch are reset to 0)
// minor and patch are reset to 0, stage and num are removed
Version("2.4.6-beta.4").inc(Version.Increase.Major) // 3.0.0Version("1.1.0-alpha.1").copy(major = 3) // 3.1.0-alpha.1A Kotlin Multiplatform library to work with semantic versioning
implementation("com.javiersc.semver:semver-core:$version")A Version must match the following format:
<major>.<minor>.<patch?>-<stage?.name>.<stage?.num>
patchandstagecan be null.
There are 3 options to build a Version.
Version("1.0.0")
Version("1.0.0-alpha.1")
Version("12.23.34-alpha.45")Version("1.0.0", "alpha.1")
Version("12.23.34", "alpha.45")Version(1, 0, 0)
Version(1, 0, 0, "alpha", 1)
Version(12, 23, 34, "alpha", 45)Version("1.0.1") > Version("1.0.0") // true
Version("1.0.1") < Version("1.0.0") // false
Version("1.0.0") == Version("1.0.0") // trueVersion("2.4.6-alpha.1").inc(Version.Increase.Patch) // 2.4.7 (stage and num are removed)
Version("2.4.6").inc(Version.Increase.Patch) // 2.4.7
Version("2.4.6").inc(Version.Increase.Minor) // 2.5.0 (patch is reset to 0)
Version("2.4.6").inc(Version.Increase.Major) // 3.0.0 (minor and patch are reset to 0)
// minor and patch are reset to 0, stage and num are removed
Version("2.4.6-beta.4").inc(Version.Increase.Major) // 3.0.0Version("1.1.0-alpha.1").copy(major = 3) // 3.1.0-alpha.1