Case sensitive version ordering

I was just reading the docs about “Version Ordering” here:

https://docs.gradle.org/current/userguide/single_versions.html#version_ordering

The examples in the following two points seem to be in conflict with eachother:

  1. If both are not numeric, the parts are compared alphabetically, case-sensitive : 1.A < 1.B < 1.a < 1.b

  2. The string SNAPSHOT has no special meaning , and is sorted alphabetically like any other string part: 1.0-alpha < 1.0-SNAPSHOT < 1.0-zeta < 1.0-rc < 1.0

The docs don’t mention alpha having any special meaning, so surely the uppercase SNAPSHOT would be lower alphabetically than the lowercase alpha? This seems to be in agreement with what I see on my project, where we have SNAPSHOT and nightly and we end up with SNAPSHOT < nightly

I had the same question when they first released those docs. I asked about it somewhere, I think in the Gradle Slack community, but never heard back (or I did and have completely forgotten). What you are observing is correct, the version comparison ends up using the standard String.compareTo method for non-numeric parts with no special meaning.
Perhaps you can do a better job than I and raise an issue on Github :slight_smile:

Thanks Chris, wanted to make sure at least someone agreed with me! I raised a PR, looks like Gradle 7 docs don’t have that bit any more since the default is the new ordering scheme Correct version ordering by wboult · Pull Request #16013 · gradle/gradle · GitHub

Thanks for raising this. That documentation is indeed wrong. I will take a look at the PR.