[ https://issues.apache.org/jira/browse/MNG-7559?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17651514#comment-17651514 ]
ASF GitHub Bot commented on MNG-7559: ------------------------------------- michael-o commented on PR #929: URL: https://github.com/apache/maven/pull/929#issuecomment-1363702902 > Hi @michael-o if I may, I think the current implementation is in line with the specification as I have a feeling that the specification has been based on it 😄 > > The problem is that the spec deviates from SemVer in how it treats non-standard qualifiers, like the "pfd" here. According to SemVer, all qualifiers should be treated as less than -.number whereas with "the spec" all non-standard qualifiers are treated as later than -.number. > > As is the case of "-pdf" which is later than the release. > > So this: > > > The docs say: > > > else ".qualifier" = "-qualifier" < "-number" < ".number > > is not exactly true. > > ```java > @Test > public void testComparableVersionWithCustomQualifier() > { > assertThat( new DefaultArtifactVersion( "2.3" ).compareTo( new DefaultArtifactVersion( "2.3-pfd" ) ), > greaterThan( 0 ) ); > } > ``` > > ``` > java.lang.AssertionError: > Expected: a value greater than <0> > but: <-2> was less than <0> > ``` > > So, adding "pfd" as a recognised qualifier would mean that the spec also needs to be updated. Which is why it's a breaking change and not a bugfix. > > Frankly, to me it looks like this behaviour contradicts the statement that "-qualifier" < "-number", but I've long given up on that. I have just re-read the spec. It says: If version strings are syntactically correct [Semantic Versioning 1.0.0](https://semver.org/spec/v1.0.0.html) version numbers, then in almost all cases version comparison follows the precedence rules outlined in that specification....Maven does not consider any semantics implied by that specification....Non-numeric tokens ("qualifiers") have the alphabetical order, except for the following tokens which come first in this order So what it does is just use the *syntax* of SemVer 1.0 and *not* the semantics. It considers only a new qualifiers as pre-release and not all, e.g., sp for service pack is a post-GA qualifier. So to me this change is change of the specs since it wants add more qualifiers to the pre-release state. So my verdict based on my understanding the dot vs hyphen issue was real and I can see it with a few manual tests. Others are not. I will remove this ticket from 3.x for obvious reasons. I think that the version scheme requires an update in 4.0, but that is a different discussion. Opinions? Side note: Looking at SemVer 2.0 I am not really happy with it: * It allows very complex qualifiers. Don't know wether that is really necessary * Our `SNAPSHOT` qualifier cannot be covered * Build qualfiiers aren't release qualifiers for me * I don't see how one can map custom qualifiers (post-release) for the case I have depicted earlier, those aren't build qualifiers. * I don't see how a build qualifier makes sense after post-release where a release is supposed to be immutable and identical according to SemVer PS: I am not happy with the ambiguity/lack of precision of the current spec > ComparableVersion vs versions with custom qualifiers > ---------------------------------------------------- > > Key: MNG-7559 > URL: https://issues.apache.org/jira/browse/MNG-7559 > Project: Maven > Issue Type: Bug > Affects Versions: 3.8.3 > Reporter: Andrzej Jarmoniuk > Assignee: Michael Osipov > Priority: Major > Fix For: 3.8.x-candidate, 3.9.0, 4.0.0-alpha-3, 4.0.0-alpha-4, > 4.0.0 > > Attachments: image-2022-10-22-18-22-11-591.png > > > Since I know that ComparableVersion was brought to Maven from > versions-maven-plugin, it turns out the bug described here: > https://github.com/mojohaus/versions-maven-plugin/issues/744 > also exists in maven, at least in 3.8.3. > According to the maven version spec, versions containing a qualifier should > be treated as less major than the same versions without the qualifier. > Currently it's only the case for a few "standard" qualifiers, e.g. "-rc*", > "-alpha", etc. > However, it looks like "2.3-pfd" is deemed less major than "2.3". > {code:java} > @Test > public void testComparableVersionWithCustomQualifier() > { > assertThat( new ComparableVersion( "2.3" ).compareTo( new > ComparableVersion( "2.3-pfd" ) ), > greaterThan( 0 ) ); > } > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)