/Strata

A library for parsing and comparing version strings

Primary LanguageJavaMIT LicenseMIT

Strata

MIT license Maven Central Pure Kotlin Discord Server

A simple, dependency-less, library for parsing and comparing version according to the SemVer spec

Features

  • Can parse any valid SemVer version.
  • Has no external dependencies other than JetBrains Annotations to help document the public API.
  • Very fast. Can parse 1 million versions in under 5 seconds. (2.1 seconds on my cpu, a Ryzen 5 3600.) At that level, speed is insignificant, unless you have a really weird usecase where you need to parse hundreds of thousands of versions a second.
  • Simple to use API.

Including

Builds can be found on Maven Central, and can be included with any build tool that supports maven.

<dependency>
  <groupId>ca.solo-studios</groupId>
  <artifactId>strata</artifactId>
  <version>1.0.0</version>
</dependency>

Gradle Groovy DSL

implementation 'ca.solo-studios:strata:1.0.0'

Gradle Kotlin DSL

implementation("ca.solo-studios:strata:1.0.0")

Examples

Getting a version

try {
    Version version = Versions.parseVersion("1.2.3");
} catch (ParseException e) {
    // handle version parse exception
}

Getting a version range

try {
    VersionRange range = Versions.parseVersionRange("[1.2.3,4.5.6)");
} catch (ParseException e) {
    // handle invalid version range parse exception
}

Checking if a version is within a version range

Version version = [...]

VersionRange range = [...]

if (range.isSatisfiedBy(version)) {
    // version is within range
} else {
    // version is outside range
}