dmlloyd commented on code in PR #406:
URL: https://github.com/apache/maven-resolver/pull/406#discussion_r1453479693


##########
maven-resolver-util/src/main/java/org/eclipse/aether/util/version/package-info.java:
##########
@@ -25,5 +25,38 @@
  * <p>
  * On the other hand, the {@link 
org.eclipse.aether.util.version.UnionVersionRange} is universal implementation 
of
  * "unions" of various {@link org.eclipse.aether.version.VersionRange} 
instances.
+ *
+ * <h1>Generic Version Spec</h1>
+ * Version string is parsed into version according to these rules below:
+ * <ul>
+ *     <li>The version string is parsed into segments, from left to right.</li>
+ *     <li>Segments are explicitly delimited by single {@code "." (dot)}, 
{@code "-" (hyphen)} or {@code "_" (underscore)} character.</li>
+ *     <li>Segments are implicitly delimited by transition between digits and 
non-digits.</li>
+ *     <li>Segments are classified as numeric, string, qualifiers (special 
case of string) and min/max.</li>
+ *     <li>Numeric segments are sorted numerically, ascending.</li>
+ *     <li>Non-numeric segments may be qualifiers (predefined) or strings 
(non-empty letter sequence). All of them are interpreted as being 
case-insensitive in terms of the ROOT locale.</li>
+ *     <li>Qualifier segments (strings listed below) and their sort order 
(ascending) are:
+ *         <ul>
+ *             <li>"alpha" (== "a" when immediately followed by number)</li>
+ *             <li>"beta" (== "b" when immediately followed by number)</li>
+ *             <li>"milestone" (== "m" when immediately followed by 
number)</li>
+ *             <li>"rc" == "cr" (use of "cr" is discouraged)</li>
+ *             <li>"snapshot"</li>
+ *             <li>"ga" == "final" == "release"</li>
+ *             <li>"sp"</li>
+ *         </ul>
+ *     </li>
+ *     <li>String segments are sorted lexicographically, per ROOT locale, 
ascending.</li>
+ *     <li>There are two special segments, {@code "min"} and {@code "max"}, 
they represent absolute minimum and absolute maximum in comparisons.</li>
+ *     <li>As last step, trailing "zero segments" are trimmed. Similarly, 
"zero segments" positioned before numeric and non-numeric transitions (either 
explicitly or implicitly delimited) are trimmed.</li>
+ *     <li>When trimming, "zero segments" are qualifiers {@code "ga"}, {@code 
"final"}, {@code "release"} only if being last (right-most) segment, empty 
string and "0" always.</li>

Review Comment:
   Why would these qualifiers not *always* be zero segments? For example I 
could have `1.0.final.1`; if I then decided to have `1.0.1.final` I'd be more 
likely to expect it to come later than `1.0.final.1` than to have it come 
before. And having context-sensitive rules is problematic for parsing IMO; it's 
better if two segments can always be compared in complete isolation than for it 
to depend on what comes before or after it. I'd use this absolute segment 
ordering in all cases:
   
   * `max`
   * qualifiers in order
       * `alpha`/`a`
       * `beta`/`b`
       * `milestone`/`m`
       * `rc`/`cr`
       * `snapshot`
   * zero segment
       * empty string
       * `final`/`ga`/`release`
       * zero
   * qualifiers in order
       * `sp`
   * positive integers (numerically)
   * other strings (lexicographically)
   * `min`
   
   Note that the existing order of qualifiers vs other strings seems to be 
opposite of what is given here.



##########
maven-resolver-util/src/main/java/org/eclipse/aether/util/version/package-info.java:
##########
@@ -25,5 +25,38 @@
  * <p>
  * On the other hand, the {@link 
org.eclipse.aether.util.version.UnionVersionRange} is universal implementation 
of
  * "unions" of various {@link org.eclipse.aether.version.VersionRange} 
instances.
+ *
+ * <h1>Generic Version Spec</h1>
+ * Version string is parsed into version according to these rules below:
+ * <ul>
+ *     <li>The version string is parsed into segments, from left to right.</li>
+ *     <li>Segments are explicitly delimited by single {@code "." (dot)}, 
{@code "-" (hyphen)} or {@code "_" (underscore)} character.</li>
+ *     <li>Segments are implicitly delimited by transition between digits and 
non-digits.</li>
+ *     <li>Segments are classified as numeric, string, qualifiers (special 
case of string) and min/max.</li>
+ *     <li>Numeric segments are sorted numerically, ascending.</li>
+ *     <li>Non-numeric segments may be qualifiers (predefined) or strings 
(non-empty letter sequence). All of them are interpreted as being 
case-insensitive in terms of the ROOT locale.</li>
+ *     <li>Qualifier segments (strings listed below) and their sort order 
(ascending) are:
+ *         <ul>
+ *             <li>"alpha" (== "a" when immediately followed by number)</li>
+ *             <li>"beta" (== "b" when immediately followed by number)</li>
+ *             <li>"milestone" (== "m" when immediately followed by 
number)</li>
+ *             <li>"rc" == "cr" (use of "cr" is discouraged)</li>
+ *             <li>"snapshot"</li>
+ *             <li>"ga" == "final" == "release"</li>
+ *             <li>"sp"</li>
+ *         </ul>
+ *     </li>
+ *     <li>String segments are sorted lexicographically, per ROOT locale, 
ascending.</li>
+ *     <li>There are two special segments, {@code "min"} and {@code "max"}, 
they represent absolute minimum and absolute maximum in comparisons.</li>
+ *     <li>As last step, trailing "zero segments" are trimmed. Similarly, 
"zero segments" positioned before numeric and non-numeric transitions (either 
explicitly or implicitly delimited) are trimmed.</li>
+ *     <li>When trimming, "zero segments" are qualifiers {@code "ga"}, {@code 
"final"}, {@code "release"} only if being last (right-most) segment, empty 
string and "0" always.</li>

Review Comment:
   Also note that today it seems that qualifiers also come before integers, so 
maybe this revised ordering which is both internally consistent and largely 
compatible with what exists today (see edited above).



-- 
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-unsubscr...@maven.apache.org

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

Reply via email to