Package-level declarations

Types

Link copied to clipboard
enum Inc : Enum<Inc>

Determines by which identifier the given Version should be incremented.

Link copied to clipboard
object LooseVersionSerializer : KSerializer<Version>

Built-in kotlinx.serialization serializer that encodes and decodes non-strict Version as its string representation.

Link copied to clipboard
@Serializable(with = VersionSerializer::class)
class Version : Comparable<Version>

This class describes a semantic version and related operations following the semver 2.0.0 specification. Instances of this class are immutable, which makes them thread-safe.

Link copied to clipboard

Version throws this exception when the semantic version parsing fails due to an invalid format.

Link copied to clipboard
object VersionSerializer : KSerializer<Version>

Built-in kotlinx.serialization serializer that encodes and decodes Version as its string representation.

Functions

Link copied to clipboard
fun Version.inc(by: Inc, preRelease: String? = null): Version

Increases the version by its Inc.MAJOR, Inc.MINOR, Inc.PATCH, or Inc.PRE_RELEASE segment.

Link copied to clipboard
fun Version.nextMajor(preRelease: String? = null): Version

Increments the version by its MAJOR number. When the preRelease parameter is set, a pre-release version will be produced from the next MAJOR version. The value of preRelease will be the first pre-release identifier of the new version.

Link copied to clipboard
fun Version.nextMinor(preRelease: String? = null): Version

Increments the version by its MINOR number. When the preRelease parameter is set, a pre-release version will be produced from the next MINOR version. The value of preRelease will be the first pre-release identifier of the new version.

Link copied to clipboard
fun Version.nextPatch(preRelease: String? = null): Version

Increments the version by its PATCH number. When the version is pre-release, the PATCH number will not be incremented, only the pre-release identifier will be removed.

Link copied to clipboard
fun Version.nextPreRelease(preRelease: String? = null): Version

Increments the version by its PRE-RELEASE identifier or produces the next pre-release of a stable version. The preRelease parameter's value is used for setting the pre-release identity when the version is stable or has a different pre-release name. If the version is already pre-release and the first identifier matches with the preRelease parameter, a simple incrementation will apply.

Link copied to clipboard
infix fun Version.satisfies(constraint: Constraint): Boolean

Determines whether a Version satisfies a Constraint or not.

Link copied to clipboard
infix fun Version.satisfiesAll(constraints: Iterable<Constraint>): Boolean

Determines whether a Version satisfies each Constraint in a collection or not.

Link copied to clipboard
infix fun Version.satisfiesAny(constraints: Iterable<Constraint>): Boolean

Determines whether a Version satisfies at least one Constraint in a collection or not.

Link copied to clipboard
fun String.toVersion(strict: Boolean = true): Version

Parses the string as a Version and returns the result or throws a VersionFormatException if the string is not a valid representation of a semantic version.

Link copied to clipboard
fun String.toVersionOrNull(strict: Boolean = true): Version?

Parses the string as a Version and returns the result or null if the string is not a valid representation of a semantic version.

Link copied to clipboard

Produces a copy of the Version without the PRE-RELEASE and BUILD METADATA identities.