The Semantic Versioning Parser is a Java library for parsing and building semantic versions according to the Semantic Version Specification. It requires Java 17 or higher.
<dependency>
<groupId>io.github.freiheitstools.semver.parser</groupId>
<artifactId>parser</artifactId>
<version>0.1.0</version>
</dependency>
Please check afterward for the latest version by running the following Maven command:
mvn versions:display-dependency-updates \
-DdependencyIncludes="io.github.freiheitstools.semver.parser:parser"
SemVerParser parser = SemVer.parser();
SemVer semver = parser.parse("1.2.3-SNAPSHOT+23");
if (semver.isInvalid()) {
System.out.println("Given semantic version is not valid");
} else {
System.out.println(semver.getMajor());
System.out.println(semver.getMinor());
System.out.println(semver.getPatch());
semver.getPreRelease().ifPresent(System.out::println);
semver.getBuild().ifPresent(System.out::println);
}
SemVerParser parser = SemVer.parser();
SemVer semVer = parser.parse("1.2.3-SNAPSHOT");
SemVer nextSemVer = SemVer.builder().startFrom(semVer)
.removePrerelease()
.build();
SemVer nextSemVer = SemVer.builder().startFrom(1, 2, 0)
.setPrerelease("SNAPSHOT")
.build();
The versioning of the Semantic Versioning Parser takes place according to the principles of Semantic Versioning. This means that the version of a release is only a statement on compatibility, not of functionality.
As every good open source project, it is never complete.