Skip to content

freiheitstools/semver-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

100 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Semantic Versioning Parser

javadoc parser GitHub Actions Status


The Semantic Versioning Parser is a Java library for parsing,building, and validating semantic versions according to the Semantic Version Specification 2.0.0. 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.

Building the Library

The projects used Apache Maven to build. So a simple call to Maven without any goal will build the library.

Building the project via Apache Maven
mvn

Disabling any style checks during the build

The project uses the Spotless to ensure a consistent layout and style for various artefacts. You can disable this check during development time by disabling the profile used to run Spotless by running Maven with -P!run-spotless-to-check-project.

Building the Library without the checks by Spotless
mvn -P!run-spotless-to-check-project

You can also add this option to your .mvn/maven.config file to persist this setting.

Disabling the profile via .mvn/maven.config
echo "-P!run-spotless-to-check-project" >> .mvn/maven.config

Using Spotless to ensure a consistent layout

To achive the required layout for various artefacts, you can call the apply goal of Spotless. Make sure that Spotless has not been disabled.

Formatting the project with Spotless
mvn spotless:apply

About

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

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages