You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "arturobernalg (via GitHub)" <gi...@apache.org> on 2026/10/16 11:51:22 UTC

[PR] Keep the zero between hyphens in the canonical form of a version (fix #8873) [maven]

arturobernalg opened a new pull request, #13572:
URL: https://github.com/apache/maven/pull/13572

   ## What and why
   
   On 3.10.x `ComparableVersion#getCanonical()` turns `1-0-1` into `1-1`, although the two compare differently (`1-0-1` < `1-1`). The parsed form is `[1, [[1]]]`, a list nested in a list, and `ListItem.toString()` only wrote the hyphen of a nested list when something had already been written before it, so the inner hyphen was lost (#8873).
   
   The issue is already fixed on master and 4.0.x by #13102, which also changes how `1.0-1` and `1-1` compare. That change is not backported here: the 3.x ordering stays as it is.
   
   ## How
   
   `ListItem.toString()` always writes the hyphen of a nested list. `1-0-1` is now `1--1`, which parses back to an equal version, and `1-0-0-1` is `1---1`. Versions without a nested list in first position, such as `1-1` and `1.0-1`, keep their canonical form. Comparison is not touched.
   
   ## Tests
   
   `ComparableVersionTest#testMng7594` fails without the change. `maven-artifact`, `maven-resolver-provider` and `maven-core` pass (420 tests) and spotless is clean. A random check of 60000 versions found 16932 whose canonical form did not parse back to an equal version before, and 956 after. The remaining ones involve empty tokens and `ga`, and are not part of this change.
   
   ---
   
   To make clear that you license your contribution under
   the [Apache License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
   check one of the following:
   
   - [x] I hereby declare this contribution to be licensed under the [Apache License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
   - [x] I hereby declare that I have filed an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Backport maven-3.10.x] Keep the zero between hyphens in the canonical form of a version (fix #8873) [maven]

Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on PR #13572:
URL: https://github.com/apache/maven/pull/13572#issuecomment-6291037343

   Note to anyone: For me, for "maven versions" the implementation is here:
   https://github.com/apache/maven-resolver/tree/master/maven-resolver-util/src/main/java/org/eclipse/aether/util/version
   
   And spec is here:
   https://github.com/apache/maven-resolver/blob/master/maven-resolver-util/src/main/java/org/eclipse/aether/util/version/package-info.java
   
   Everything else (including maven-artifact) for me is _deprecated_ and duplication that somewhere in the future, we need to get rid of. 
   
   That said, the two must be kept as close to each other as possible. 
   
   @arturobernalg please recheck does this PR adds some "drift" between the two and report back please.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Backport maven-3.10.x] Keep the zero between hyphens in the canonical form of a version (fix #8873) [maven]

Posted by "arturobernalg (via GitHub)" <gi...@apache.org>.
arturobernalg commented on PR #13572:
URL: https://github.com/apache/maven/pull/13572#issuecomment-6291139529

   Checked GenericVersion in maven-resolver-util: no drift, because there's nothing to drift from. It doesn't build a nested list structure like ComparableVersion's ListItem, and its toString() just returns the original input string rather than reconstructing a canonical form from the parsed items. The bug this PR fixes (ListItem.toString() dropping a hyphen) has no counterpart there. Comparison logic (compareTo) isn't touched by this PR either way.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Backport maven-3.10.x] Keep the zero between hyphens in the canonical form of a version (fix #8873) [maven]

Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on PR #13572:
URL: https://github.com/apache/maven/pull/13572#issuecomment-6293164280

   Thanks!
   @arturobernalg Given the amount of your contributions, would you sign CLA? 
   https://www.apache.org/licenses/contributor-agreements.html
   (ignore if you already did)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Backport maven-3.10.x] Keep the zero between hyphens in the canonical form of a version (fix #8873) [maven]

Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas merged PR #13572:
URL: https://github.com/apache/maven/pull/13572


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org