DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
| Info | ||
|---|---|---|
| ||
page copied from MAVENOLD to MAVEN here |
issue tracked as MNG-3010
Improve default support for version schemes
...
The unit tests that are there to test comparison only check for a few cases with snapshots. When all tests
(version A < version B) are expanded to also test for SNAPSHOTs (version A-SNAPSHOT < version B-SNAPSHOT) a
lot of the tests fail.
Left | Op | Right |
|---|
Left | Op | Right |
|---|
1 | = | 1 | 1-SNAPSHOT | = | 1-SNAPSHOT |
1 | < | 2 | 1-SNAPSHOT | < | 2-SNAPSHOT |
1.5 | < | 2 | 1.5-SNAPSHOT | < | 2-SNAPSHOT |
1 | < | 2.5 | 1-SNAPSHOT | < | 2.5-SNAPSHOT |
1 | = | 1.0 | 1-SNAPSHOT | = | 1.0-SNAPSHOT |
1 | = | 1.0.0 | 1-SNAPSHOT | = | 1.0.0-SNAPSHOT |
1.0 | < | 1.1 | 1.0-SNAPSHOT | < | 1.1-SNAPSHOT |
1.1 | < | 1.2 | 1.1-SNAPSHOT | < | 1.2-SNAPSHOT |
1.0.0 | < | 1.1 | 1.0.0-SNAPSHOT | < | 1.1-SNAPSHOT |
1.1 | < | 1.2.0 | 1.1-SNAPSHOT | < | 1.2.0-SNAPSHOT |
1.0-alpha-1 | < | 1.0 | 1.0-alpha-1-SNAPSHOT | < | 1.0-SNAPSHOT |
1.0-alpha-1 | < | 1.0-alpha-2 | 1.0-alpha-1-SNAPSHOT | < | 1.0-alpha-2-SNAPSHOT |
1.0-alpha-1 | < | 1.0-beta-1 | 1.0-alpha-1-SNAPSHOT | < | 1.0-beta-1-SNAPSHOT |
1.0 | < | 1.0-1 | 1.0-SNAPSHOT | < | 1.0-1-SNAPSHOT |
1.0-1 | < | 1.0-2 | 1.0-1-SNAPSHOT | < | 1.0-2-SNAPSHOT |
2.0-0 | = | 2.0 | 2.0-0-SNAPSHOT | = | 2.0-SNAPSHOT |
2.0 | < | 2.0-1 | 2.0-SNAPSHOT | < | 2.0-1-SNAPSHOT |
2.0.0 | < | 2.0-1 | 2.0.0-SNAPSHOT | < | 2.0-1-SNAPSHOT |
2.0-1 | < | 2.0.1 | 2.0-1-SNAPSHOT | < | 2.0.1-SNAPSHOT |
2.0.1-klm | < | 2.0.1-lmn | 2.0.1-klm-SNAPSHOT | < | 2.0.1-lmn-SNAPSHOT |
2.0.1-xyz | < | 2.0.1 | 2.0.1-xyz-SNAPSHOT | < | 2.0.1-SNAPSHOT | notice that the proposal reverted the order: in Maven 2, 2.0.1-xyz < 2.0.1 but in Maven 3, 2.0.1 < 2.0.1-xyz | ||
2.0.1 | < | 2.0.1-123 | 2.0.1-SNAPSHOT | < | 2.0.1-123-SNAPSHOT |
2.0.1-xyz | < | 2.0.1-123 | 2.0.1-xyz-SNAPSHOT | < | 2.0.1-123-SNAPSHOT |
Proposal
I'm proposing the following implementation: GenericArtifactVersion.java (unit test: GenericArtifactVersionTest.java). It has been integrated in artifact 3.0-SNAPSHOT r656775(15/5/2008) as ComparableVersion.java.
...
ordering rules when comparing version components:
...
Integer | String | List | null | |
|---|---|---|---|---|
Integer | Highest is newer | Integer is newer | Integer is newer | If integer==0 then equal, |
String | Integer is newer | order by well-known | List is newer | Compare with "" |
List | Integer is newer | List is newer | Version itself is a list; compare item by item | Compare with empty list item (recursion) |
null | If integer==0 then equal, | Compare with "" | Compare with empty list item (recursion) | doesn't happen |
Special note on string comparing:
A predefined list of well-known qualifiers is present. For comparison, the string is converted to another string, as follows:
...