jay23606 opened a new pull request, #13890: URL: https://github.com/apache/maven/pull/13890
## Problem `ComparableVersion#getCanonical()` concatenates a qualifier and its number without a separator, because `CombinationItem#toString()` returns `stringPart + digitPart`. Since MNG-7714 a qualifier followed by a number is parsed into one `CombinationItem`, so Maven 4 spells some versions differently from Maven 3: | Version | Maven 3 | Maven 4 (before this change) | |---|---|---| | `3.0.0-M2` | `3-milestone-2` | `3-milestone2` | | `4.0.0-beta-1` | `4-beta-1` | `4-beta1` | | `3.34.0.CR1` | `3.34-rc-1` | `3.34-rc1` | | `1.0-sp1` | `1-sp-1` | `1-sp1` | Plugins that read the canonical form (for example to classify `alpha`/`beta`/`milestone`/`rc` items split on `.` and `-`) see different results under Maven 4. ## Change `CombinationItem#toString()` now writes the separator: `stringPart + "-" + digitPart`. Ordering, `equals` and `hashCode` are unchanged. The canonical form still parses back to an equal version, which the existing round-trip check in `ComparableVersionTest#newComparable` continues to verify for every version literal in that test class. ## Testing Added `ComparableVersionTest#testQualifierWithNumberCanonicalSpelling`, which asserts the four canonical forms above. On the unfixed code it fails with `expected: <3-milestone-2> but was: <3-milestone2>`; after the change it passes. Run here: - `mvn -o -q -B -pl compat/maven-artifact test -Dtest=ComparableVersionTest -Dsurefire.failIfNoSpecifiedTests=false -Dspotless.check.skip=true -Drat.skip=true -Denforcer.skip=true` (exit 0 after the fix) - `mvn -o -q -B -pl compat/maven-artifact test -Dspotless.check.skip=true -Drat.skip=true -Denforcer.skip=true` (whole module, exit 0) Spotless and RAT were skipped on these runs, so formatting has not been checked by the tool; CI will run them. **Regression test:** fails on base twice (/expected: <3-milestone-2> but was: <3-milestone2>/), passes on fix twice (`mvn -o -q -B -pl compat/maven-artifact test -Dtest=ComparableVersionTest -Dsurefire.failIfNoSpecifiedTests=false -Dspotless.check.skip=true -Drat.skip=true -Denforcer.skip=true`) Fixes #13889 -- 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]
