@@ -18,6 +18,7 @@ The following version and version constraint schemes are supported:
1818* [ RubyGems] ( https://rubygems.org/ )
1919* [ Semantic Versioning] ( https://semver.org/ )
2020* [ Calendar Versioning] ( https://calver.org/ )
21+ * [ Debian Package Versioning] ( https://www.debian.org/doc/debian-policy/ch-controlfields.html#version )
2122
2223## Usage
2324See the [ examples folder] ( examples ) for complete working code demonstrating the usage of this library. The
@@ -27,19 +28,20 @@ following Maven dependency:
2728<dependency >
2829 <groupId >org.cthing</groupId >
2930 <artifactId >versionparser</artifactId >
30- <version >5.0 .0</version >
31+ <version >5.1 .0</version >
3132</dependency >
3233```
3334or the following Gradle dependency:
3435``` kotlin
35- implementation(" org.cthing:versionparser:5.0 .0" )
36+ implementation(" org.cthing:versionparser:5.1 .0" )
3637```
3738
3839### Versioning Overview
3940
4041| Scheme | Version Factory | Version Constraint Factory |
4142| ----------| ---------------------------------------------------| -----------------------------------------------|
4243| Calendar | ` CalendarVersionScheme.parse(String) ` <sup >1</sup > | N/A |
44+ | Debian | ` DebVersionScheme.parseVersion(String) ` | ` DebVersionScheme.parseConstraint(String) ` |
4345| Gradle | ` GradleVersionScheme.parseVersion(String) ` | ` GradleVersionScheme.parseConstraint(String) ` |
4446| Java | ` JavaVersionScheme.parseVersion(String) ` | ` JavaVersionScheme.parseRange(String) ` |
4547| Maven | ` MvnVersionScheme.parseVersion(String) ` | ` MvnVersionScheme.parseConstraint(String) ` |
@@ -321,6 +323,34 @@ assertThat(component1.getCategory()).isEqualTo(ComponentCategory.YEAR);
321323assertThat(version2. compareTo(version3)). isEqualTo(- 1 );
322324```
323325
326+ ### Debian Packageg Versioning
327+ Support is provided for parsing Debian package versions and version constraints.
328+
329+ ``` java
330+ // Parse versions
331+ final DebVersion version1 = DebVersionScheme . parseVersion(" 22.07.5-2ubuntu1.5" );
332+ final Version version2 = DebVersionScheme . parseVersion(" 20.01.2-1ubuntu1.5" );
333+
334+ // Obtain information from the parsed version
335+ assertThat(version1. getOriginalVersion()). isEqualTo(" 22.07.5-2ubuntu1.5" );
336+ assertThat(version1. isPreRelease()). isFalse();
337+ assertThat(version1. getEpoch()). isEqualTo(0 );
338+ assertThat(version1. getUpstream()). isEqualTo(" 22.07.5" );
339+ assertThat(version1. getRevision()). isEqualTo(" 2ubuntu1.5" );
340+
341+ // Verify ordering
342+ assertThat(version1. compareTo(version2)). isEqualTo(1 );
343+
344+ // Parse version constraints
345+ final VersionConstraint constraint1 = DebVersionScheme . parseConstraint(" >20" );
346+ final VersionConstraint constraint2 = DebVersionScheme . parseConstraint(" >21 <=23" );
347+
348+ // Perform constraint checking
349+ assertThat(constraint1. allows(version2)). isTrue();
350+ assertThat(constraint2. allows(version1)). isTrue();
351+ assertThat(constraint2. allows(version2)). isFalse();
352+ ```
353+
324354## Additional Information
325355In preparation for creating this library, a [ survey of many popular versioning schemes] ( docs/VersioningSurvey.md ) was conducted.
326356Among other things, this lead to the recognition that all version constraint specifications could be expressed using a single notation.
0 commit comments