trackoor opened a new issue, #14031: URL: https://github.com/apache/maven/issues/14031
### Affected version 4.0.0-rc-7 (since 4.0.0-alpha-7; also on master `bd1d610413` and maven-4.0.x `ce97d6be0d`) ### Bug description In Maven 4 (`compat/maven-artifact`), `ComparableVersion` expands single-letter `a`, `b`, and `m` qualifiers to `alpha`, `beta`, and `milestone` across a `-` separator (`3-a-1`, `3-b-1`, `3-m-1`), sorting them before `3` even though `3-a` sorts after `3`. Steps to reproduce: ```sh curl -fsSLO https://repo1.maven.org/maven2/org/apache/maven/maven-artifact/4.0.0-rc-7/maven-artifact-4.0.0-rc-7.jar curl -fsSLO https://repo1.maven.org/maven2/org/apache/maven/maven-artifact/3.10.1/maven-artifact-3.10.1.jar java -jar maven-artifact-4.0.0-rc-7.jar 3-alpha-1 3-a1 3-a-1 3 3-a java -jar maven-artifact-3.10.1.jar 3-alpha-1 3-a1 3-a-1 3 3-a ``` Actual output with `maven-artifact-4.0.0-rc-7.jar`: ```text Display parameters as parsed by Maven (in canonical form and as a list of tokens) and comparison result: 1. 3-alpha-1 -> 3-alpha1; tokens: [3, [alpha1]] 3-alpha-1 == 3-a1 2. 3-a1 -> 3-alpha1; tokens: [3, [alpha1]] 3-a1 == 3-a-1 3. 3-a-1 -> 3-alpha1; tokens: [3, [alpha1]] 3-a-1 < 3 4. 3 -> 3; tokens: [3] 3 < 3-a 5. 3-a -> 3-a; tokens: [3, [a]] ``` On `master` (`bd1d61041394fe485bb2902a6dc063290bb6ad8a`) and `maven-4.0.x` (`ce97d6be0deeea46fbe706e9e86cedaae2e17d60`, after #13890 / #13898), `getCanonical()` rewrites `3-a-1` to `3-alpha-1` with the same ordering: ```text Display parameters as parsed by Maven (in canonical form and as a list of tokens) and comparison result: 1. 3-alpha-1 -> 3-alpha-1; tokens: [3, [alpha-1]] 3-alpha-1 == 3-a1 2. 3-a1 -> 3-alpha-1; tokens: [3, [alpha-1]] 3-a1 == 3-a-1 3. 3-a-1 -> 3-alpha-1; tokens: [3, [alpha-1]] 3-a-1 < 3 4. 3 -> 3; tokens: [3] 3 < 3-a 5. 3-a -> 3-a; tokens: [3, [a]] ``` `3-b-1` and `3-m-1` behave the same way (`3-b-1 == 3-beta-1 < 3` and `3-m-1 == 3-milestone-1 < 3`). Expected output (matching `maven-artifact` `3.10.1`, `3.9.16`, `4.0.0-alpha-5`, and Maven 4 `maven-resolver` `GenericVersion`): ```text Display parameters as parsed by Maven (in canonical form and as a list of tokens) and comparison result: 1. 3-alpha-1 -> 3-alpha-1; tokens: [3, [alpha, [1]]] 3-alpha-1 == 3-a1 2. 3-a1 -> 3-alpha-1; tokens: [3, [alpha, [1]]] 3-a1 < 3-a-1 3. 3-a-1 -> 3-a-1; tokens: [3, [a, [1]]] 3-a-1 > 3 4. 3 -> 3; tokens: [3] 3 < 3-a 5. 3-a -> 3-a; tokens: [3, [a]] ``` Per the [POM Version Order Specification](https://maven.apache.org/pom.html#version-order-specification), `a`, `b`, and `m` are aliases for `alpha`, `beta`, and `milestone` only when directly followed by a number (`3-a1 == 3-alpha-1 < 3`), whereas in `3-a-1` the `a` token is separated from `1` by `-` and is an ordinary qualifier sorting after `3` (`3 < 3-a-1`). Since #1099 (MNG-7714), `parseVersion` / `parseItem` merges `X-<digit>` via `new CombinationItem(buf.replace("-", ""))`, stripping `-` before `CombinationItem` constructs `new StringItem(value.substring(0, index), true)` with `followedByDigit = true`. Tested with OpenJDK `17.0.21` (`17.0.21+9-1-deb12u1`, Debian 12 `x86_64`). Credit: https://ucsbplse.github.io/ -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
