semver-j

Semantic Versioning library for Java

License

License

GroupId

GroupId

com.github.pawelj-pl
ArtifactId

ArtifactId

semver-j
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

semver-j
Semantic Versioning library for Java
Project URL

Project URL

https://github.com/PawelJ-PL/semver-j
Source Code Management

Source Code Management

https://github.com/PawelJ-PL/semver-j.git

Download semver-j

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.pawelj-pl/semver-j/ -->
<dependency>
    <groupId>com.github.pawelj-pl</groupId>
    <artifactId>semver-j</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.pawelj-pl/semver-j/
implementation 'com.github.pawelj-pl:semver-j:1.0.0'
// https://jarcasting.com/artifacts/com.github.pawelj-pl/semver-j/
implementation ("com.github.pawelj-pl:semver-j:1.0.0")
'com.github.pawelj-pl:semver-j:jar:1.0.0'
<dependency org="com.github.pawelj-pl" name="semver-j" rev="1.0.0">
  <artifact name="semver-j" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.pawelj-pl', module='semver-j', version='1.0.0')
)
libraryDependencies += "com.github.pawelj-pl" % "semver-j" % "1.0.0"
[com.github.pawelj-pl/semver-j "1.0.0"]

Dependencies

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
org.assertj : assertj-core jar 3.8.0

Project Modules

There are no modules declared in this project.

SemVer-J

Description

Library for representation of semantic version

Usage

Examples:

import com.github.pawelj_pl.semver_j.SemanticVersion;

SemanticVersion version1 = SemanticVersion.fromString("0.1.16-BETA+1000a");
SemanticVersion version2 = new SemanticVersion(0, 2, 20, "BETA", "2000a");

Integer major = version1.getMajor(); // value 0
Integer minor = version1.getMinor(); // value 1
Integer patch = version1.getPatch(); // value 16
Optional<String> preRelease = version1.getPreRelease(); // value Optional of BETA
Optional<String> buildMetadata = version1.getBuildMetadata(); // value Optional of 1000a

SemanticVersion v3 = version1.newMajor(3); // value SemanticVersion(3, 1, 16, "BETA", "1000a")
SemanticVersion v4 = version1.newMinor(3); // value SemanticVersion(0, 3, 16, "BETA", "1000a")
SemanticVersion v5 = version1.newPatch(3); // value SemanticVersion(0, 1, 3, "BETA", "1000a")
SemanticVersion v6 = version1.newPreRelease("ALFA"); // value SemanticVersion(0, 1, 16, "ALFA", "1000a")
SemanticVersion v7 = version1.newBuildMetadata("1000b"); // value SemanticVersion(0, 1, 16, "BETA", "1000b")

SemanticVersion v8 = version1.incrementMajor(); // value SemanticVersion(1, 1, 16, "BETA", "1000a")
SemanticVersion v9 = version1.incrementMinor(); // value SemanticVersion(0, 2, 16, "BETA", "1000a")
SemanticVersion v10 = version1.incrementPatch(); // value SemanticVersion(0, 1, 17, "BETA", "1000a")

SemanticVersion v11 = version1.copy(); //value SemanticVersion(0, 1, 16, "BETA", "1000a")

Comparing

SemanticVersion class implements Comparable interface, so two instances can be compared to each other using Semantic Versioning rules.

Versions

Version
1.0.0