You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Dennis Lundberg (Jira)" <ji...@apache.org> on 2020/07/21 07:49:00 UTC

[jira] [Commented] (MNG-6964) Maven version sorting is internally inconsistent

    [ https://issues.apache.org/jira/browse/MNG-6964?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17161830#comment-17161830 ] 

Dennis Lundberg commented on MNG-6964:
--------------------------------------

You can read about how the sorting of versions work here:
https://maven.apache.org/pom.html#version-order-specification

It seems that you are mixing dots '.' and hyphen '-' as if they are interchangeable, but they are not. They have an important meaning when parsing a version number. It says on the above page:

_"This gives a sequence of version numbers (numeric tokens) and version qualifiers (non-numeric tokens) with "." or "-" prefixes."_

In your first console example you use the versions 1-0.beta and 1-0.alpha, but in your conclusion you use 1-0.beta and 1.0.alpha. Note that the difference between dots and hyphens. 1-0.alpha is not the same as 1.0.alpha.

> Maven version sorting is internally inconsistent
> ------------------------------------------------
>
>                 Key: MNG-6964
>                 URL: https://issues.apache.org/jira/browse/MNG-6964
>             Project: Maven
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.6.3
>            Reporter: David M. Lloyd
>            Priority: Major
>
> There's a bug where version sorting is inconsistent. This manifests like this:
> {code}
> $ java -jar ~/local/apache-maven/lib/maven-artifact-3.6.3.jar 1-0.alpha 1
> Display parameters as parsed by Maven (in canonical form) and comparison result:
> 1. 1-0.alpha == 1-0.alpha
>    1-0.alpha == 1
> 2. 1 == 1
> $ java -jar ~/local/apache-maven/lib/maven-artifact-3.6.3.jar 1-0.beta 1
> Display parameters as parsed by Maven (in canonical form) and comparison result:
> 1. 1-0.beta == 1-0.beta
>    1-0.beta == 1
> 2. 1 == 1
> $ java -jar ~/local/apache-maven/lib/maven-artifact-3.6.3.jar 1-0.beta 1-0.alpha
> Display parameters as parsed by Maven (in canonical form) and comparison result:
> 1. 1-0.beta == 1-0.beta
>    1-0.beta > 1-0.alpha
> 2. 1-0.alpha == 1-0.alpha
> {code}
> Thus there is no correct total order: {{1-0.beta > 1.0.alpha}} even though both {{1-0.beta}} and {{1.0.alpha}} are equal to {{1}}.
> I think this is likely due to a logical bug where any dot-separated segments following a zero or release ({{ga}} or {{final}}) is simply truncated in certain circumstances:
> {code}
> $ java -jar ~/local/apache-maven/lib/maven-artifact-3.6.3.jar 1-0.x 1-0
> Display parameters as parsed by Maven (in canonical form) and comparison result:
> 1. 1-0.x == 1-0.x
>    1-0.x == 1-0
> 2. 1-0 == 1
> {code}
> but
> {code}
> $ java -jar ~/local/apache-maven/lib/maven-artifact-3.6.3.jar 1-0.x-1 1-0-1
> Display parameters as parsed by Maven (in canonical form) and comparison result:
> 1. 1-0.x-1 == 1-0.x-1
>    1-0.x-1 > 1-0-1
> 2. 1-0-1 == 1-1
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)