0

It is mentioned here that

If you do not follow Maven versioning standards in your project versioning scheme, then for version comparison, Maven interprets the entire version as a simple string

From the example, we can see that 1.0.9.3 should be treated the more updated than 1.0.10.1

1.0.1.0 
1.0.10.1
1.0.10.2
1.0.9.3 < most updated version

There is a project I am currently working on. It has a dependency on a package com.example.http, which is versioned 1.0.12.2. There are several updates on it now. A subset of the versions are (1.0.0, 1.0.9, 1.0.12.2, 1.0.16). Since it does not follow Maven versioning standards, I would expect the order of these versions to be:

1.0.0
1.0.12.2
1.0.16
1.0.9

Q1: However, when I run mvn versions:display-dependency-updates, it said that 1.0.16 was the most updated version. Why?

Q2: Should I do something to removed the non-standard 1.0.12.2? notes: all, but 1.0.12.x, follows the maven versioning standard

[INFO] com.example:http ............................ 1.0.12.2 -> 1.0.16

chakwok
  • 980
  • 8
  • 21
  • 1
    First the link you gave is simply not correct anymore cause this was right for Maven 2.X but I hope you are using Maven 3.X ? Furthermore why should a version 1.0.9.3 more recent than a version 1.0.10.2. That makes simply no sense..Another question: Why does a project produce versions which do not follow things like semantical versions and contradiction to any logic? – khmarbaise Jun 28 '19 at 06:44
  • @khmarbaise Thanks for the info. I am only saying `1.0.9.3` should be more recent than `1.0.10.2`. I just expected that behavior since the what the (outdated) docs said so. Just curious is there any best-practice or convention to follow with the latest version? – chakwok Jun 28 '19 at 06:53
  • Yes simply follow semantical versioning https://semver.org/ and apart from that `1.0.9.3` is simply older than `1.0.10.2`..order 1.0.9.3, 1.0.9.4 etc. and then 1.0.10.0, 1.0.10.1 and 1.0.10.3 ...The docs are from Oracle and simply wrong and are not related to the Apache Maven project. Read my blog post which JF Meier mentioned...BTW: Please change your post and in particular the quoting which is from that link and mark it as not valid anymore !! – khmarbaise Jun 28 '19 at 08:41

1 Answers1

2

The mechanism changed about 10 years ago, so your information is outdated. Maven is able to sort arbitrarily long version numbers, see e.g. https://blog.soebes.de/blog/2017/02/04/apache-maven-how-version-comparison-works/

More information can also be found in the answer https://stackoverflow.com/a/31482463/927493

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
  • Thanks. I see it is more versioning is more flexible now than before. Just curious is there any best-practice or convention to follow with the latest version? – chakwok Jun 28 '19 at 06:51
  • AFAIK, many people use version numbers with three or four numbers, either `major.minor.bugfix` or `major.minor.bugfix-buildnumber`. Depending on the context, you might want to use endings like BETA, RC or SP. – J Fabian Meier Jun 28 '19 at 07:07