Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Implementation of the SemVer Specification — strictly follows npm semantics

License

NotificationsYou must be signed in to change notification settings

yuchi/java-npm-semver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a direct portnode-semver, great to have npm like semantics in a Java application.

Releases

Available in theMaven Central repository.

Maven configuration

<dependency>  <groupId>com.github.yuchi</groupId>  <artifactId>npm-semver</artifactId>  <version>1.0.0</version></dependency>

Gradle configuration

compilegroup:"com.github.yuchi",name:"npm-semver",version:"1.0.0"// orcompile"com.github.yuchi:npm-semver:1.0.0"

Quick usage

Versionversion =Version.from("1.2.3");Rangerange =Range.from("^1.2.0");range.test(version)// true

Full Usage

Version comparison

booleanloose =false;Versionv1 =Version.from("1.2.3",loose);Stringv2 =Version.from("1.3.0",loose);v1.compareTo(v2);// -1v2.compareTo(v1);// +1v1.compareTo(v1);//  0

In Range tests

booleanloose =false;Versionv =Version.from("1.2.3",loose);Ranger =Range.from("^1.0.0",loose);r.test(v);// true

Range boundaries test

booleanloose =false;SemVer.isGreaterThenRange("1.3.0",">1.0.0 <1.4.0",loose);// falseSemVer.isGreaterThenRange("1.5.0",">1.0.0 <1.4.0",loose);// trueSemVer.isGreaterThenRange("0.9.0",">1.0.0 <1.4.0",loose);// falseSemVer.isLessThenRange("1.3.0",">1.0.0 <1.4.0",loose);// falseSemVer.isLessThenRange("1.5.0",">1.0.0 <1.4.0",loose);// falseSemVer.isLessThenRange("0.9.0",">1.0.0 <1.4.0",loose);// true

Sorting

List<Version>versions =newArrayList<Version>();versions.add(Version.from("4.2.0",false));versions.add(Version.from("1.8.0",false));versions.add(Version.from("1.2.0",false));versions.sort(newVersionComparator());// { "4.2.0", "1.8.0", "1.2.0" }

Versions Stream filtering

List<Version>versions =newArrayList<Version>();versions.add(Version.from("4.2.0",false));versions.add(Version.from("1.8.0",false));versions.add(Version.from("1.2.0",false));Rangerange =Range.from(">3.0.0",false);version.stream().filter(range::test);// { "4.2.0" }

Publishing

$ trash build$ trash tmp$ mkdir tmp$ gradle clean preparePublish publish$ gradle clean preparePublish publish # yes you need to launch it twice

License

This library,java-npm-semver, is free software ("Licensed Software"); you canredistribute it and/or modify it under the terms of theGNU Lesser GeneralPublic License as published by theFree Software Foundation; either version 2.1 of the License, or (at youroption) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANYWARRANTY; including but not limited to, the implied warranty of MERCHANTABILITY,NONINFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser GeneralPublic License for more details.

You should have received a copy of theGNU Lesser General PublicLicense along with this library; ifnot, write to the Free Software Foundation, Inc., 51 Franklin Street, FifthFloor, Boston, MA 02110-1301 USA

About

Implementation of the SemVer Specification — strictly follows npm semantics

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2026 Movatter.jp