Skip to content

Java library for parsing and working with semantic versions according to the SemVer specification.

License

Notifications You must be signed in to change notification settings

freiheitstools/semver-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Semantic Versioning Parser

javadoc parser GitHub Actions Status


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.

Maven Dependency

Maven Dependency Declartion for the library
<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:

Use Maven to check for the latest Maven version
mvn versions:display-dependency-updates \
  -DdependencyIncludes="io.github.freiheitstools.semver.parser:parser"

Usage Examples

Parsing a given Semantic Version
 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);
 }
Building a new Semantic Version from an existing one
SemVerParser parser = SemVer.parser();
SemVer semVer = parser.parse("1.2.3-SNAPSHOT");

SemVer nextSemVer = SemVer.builder().startFrom(semVer)
                          .removePrerelease()
                          .build();
Building a new Semantic Version from scratch
SemVer nextSemVer = SemVer.builder().startFrom(1, 2, 0)
                          .setPrerelease("SNAPSHOT")
                          .build();

Versioning of the Library

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.

About

Java library for parsing and working with semantic versions according to the SemVer specification.

Topics

Resources

License

Stars

Watchers

Forks

Languages