This is an automated email from the ASF dual-hosted git repository. elharo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-site.git
The following commit(s) were added to refs/heads/master by this push: new 0645fbd6 Maven compares version strings in case insensitive fashion. (#689) 0645fbd6 is described below commit 0645fbd6c298a362ebfdd2ed3568e5b28ca36342 Author: Elliotte Rusty Harold <elh...@users.noreply.github.com> AuthorDate: Sun Feb 16 16:52:19 2025 +0000 Maven compares version strings in case insensitive fashion. (#689) --- content/apt/pom.apt.vm | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/content/apt/pom.apt.vm b/content/apt/pom.apt.vm index 4f86df0e..4516aaa8 100644 --- a/content/apt/pom.apt.vm +++ b/content/apt/pom.apt.vm @@ -358,16 +358,20 @@ mvn install:install-file -Dfile=non-maven-proj.jar -DgroupId=some.group -Dartifa **** Version Order Specification If version strings are syntactically correct {{{https://semver.org/spec/v1.0.0.html}Semantic Versioning 1.0.0}} - version numbers, then in almost all cases version comparison follows the precedence rules outlined in that specification. + version numbers, then in most cases version comparison follows the precedence rules outlined in that specification. These versions are the commonly encountered alphanumeric ASCII strings such as 2.15.2-alpha. - More precisely, this is true if both version numbers to be compared match the "valid semver" - production in the BNF grammar in the semantic versioning specification. - Maven does not consider any semantics implied by that specification. + More precisely, this is true if both version strings to be compared match the "valid semver" + production in the BNF grammar for semantic versioning and both version strings only + use lower case letters. Maven does not consider any semantics implied by Semantic Versioning. <<Important>>: This is only true for Semantic Versioning <1.0.0>. The Maven version order algorithm is not compatible with Semantic Versioning <2.0.0>. In particular, Maven does not special case the plus sign or consider build identifiers. + <<Important>>: Maven compares version strings using case insensitive rules. Semver is + case sensitive. Thus in Semver, 3.2-ALPHA1 compares greater than 3.2-alpha1. In Maven + 3.2-ALPHA1 compares equal to 3.2-alpha1. + When version strings do not follow semantic versioning, a more complex set of rules is required. The Maven coordinate is split into tokens between dots ('<<<.>>>'), hyphens ('<<<->>>'), underscores ('<<<_>>>'), and transitions between digits and characters. The separator is recorded and will have effect on the order. A transition @@ -405,8 +409,9 @@ mvn install:install-file -Dfile=non-maven-proj.jar -DgroupId=some.group -Dartifa [] - The version order is the <<<lexicographical order>>> on this sequence of prefixed tokens, the shorter one - padded with enough "null" values with matching prefix to have the same length as the longer one. Padded "null" values depend on the prefix of the other version: 0 for '.', "" for '-'. + The version order is the <<<lexicographic order>>> on this sequence of prefixed tokens, the shorter one + padded with enough "null" values with matching prefix to have the same length as the longer one. + Padded "null" values depend on the prefix of the other version: 0 for '.', "" for '-'. The prefixed token order is: * if the prefix is the same, then compare the token: @@ -421,6 +426,8 @@ mvn install:install-file -Dfile=non-maven-proj.jar -DgroupId=some.group -Dartifa * Alphabetic tokens other than the special cases described above come before numeric tokens. + * Alphabetic tokens are compared in a case insensitive fashion in the {{{https://docs.oracle.com/javase/8/docs/api/java/util/Locale.html#ENGLISH}English locale}}}. For example, "A" and "a" are treated the same as are "i" and "I" and "é" and "É". + * else "<<<.qualifier>>>" = "<<<-qualifier>>>" \< "<<<-number>>>" \< "<<<.number>>>" * <<<alpha>>> = <<<a>>> < <<<beta>>> = <<<b>>> < <<<milestone>>> = <<<m>>> < <<<rc>>> = <<<cr>>> < <<<snapshot>>> < '<<<>>>' = <<<final>>> = <<<ga>>> = <<<release>>> \< <<<sp>>> @@ -441,6 +448,8 @@ mvn install:install-file -Dfile=non-maven-proj.jar -DgroupId=some.group -Dartifa * Avoid non-ASCII characters, including non-ASCII digits, which may sort in surprising ways. + * Avoid upper case characters. + [] End Result Examples: @@ -463,6 +472,8 @@ mvn install:install-file -Dfile=non-maven-proj.jar -DgroupId=some.group -Dartifa * "<<<1-a1>>>" = "<<<1-alpha-1>>>" + * "<<<1.0-alpha1>>>" = "<<<1.0-ALPHA1>>>" (case insensitivity) + * "<<<1.7>>>" \> "1.K" * "<<5.zebra>>>" \> "5.aardvark"