so far so good. Now let us assume we have the following two versions:
What would you expect which version is newer than the other or the older one?
I suppose you would say: 22.214.171.124.1 is older than 126.96.36.199 or with other
words: 188.8.131.52 is newer than 184.108.40.206.1 or to express it in a more
220.127.116.11.1 < 18.104.22.168
Or another example:
So I assume that you have expected that Maven 2 should have handled that like this:
1.0alpha10 > 1.0alpha2
Unfortunately Maven 2 had handled them different because the previous versions
did not follow the above pattern which results into string based comparison of
the versions and finally into the following result:
22.214.171.124.1 > 126.96.36.199
1.0alpha10 < 1.0alpha2
which is obviously not the result you have expected.
Starting with Maven 3 (released 2010!) the version comparison has been changed
but unfortunately the above myth keeps tenaciously.
So the first thing is that you can use as many digits as you like and separate them
by dots. This means the following versions are valid:
Regarding the above list which version is mathematically greater,
greater or equal, less than, less or equal than the other?
So what about things like 1.6.0-RC1 ? Let us assume we have the following
So how does the comparison result look like? If you think a little you might
already know the solution. The 1.6.0-RC1 is of course older than 1.6.0 or
1.6.0-RC1 < 1.6.0
This is because a release candidate is created before the final 1.6.0
release. So other things could be concluded out of the above like this:
which is this way based on the assumption made above. Milestones are before the
final releases. So of course you can conclude ordering of milestones like this:
1.6.0-m1 < 1.6.0-m4
1.6.0-m4 < 1.6.0-m10
The above is also valid for the cases where we separate the milestone via a
dot instead of a dash.
1.6.0.m1 < 1.6.0.m4
1.6.0.m4 < 1.6.0.m10
You can do things like the following if you like:
1.6.0-m188.8.131.52 < 1.6.0-m184.108.40.206
So now we come to an important thing, if we compare the following
two versions 1.6.0-m1 with 1.6.0.m1. On the first glance
you might think those two versions are equal because they describe
a milestone with the same version 1.6.0. The result of the comparison
in Maven is different:
1.6.0-m1 < 1.6.0.m1
This means in consequence that a part which is separated via - is less important
than a part wich is separated via ., or the part which is separated via .
has precedence over the part which is separated via -.
We have only considered releases yet. So now let us take a look at SNAPSHOTs.
So let us try to see which version is before the other one in case of such
version 1.6.0-SNASPHOT and 1.6.0.m1? So you might already know the result.
The SNAPSHOT version is before the other one 1.6.0.m1 cause a SNAPSHOT means
there has no release before of 1.6.0.
You can add the -SNAPSHOT part to each of the above examples but the results
will keep the same.
If you like to experiment with some of the above examples or check your ideas
you can simply use your existing(?) Maven installation for this. Starting with
Maven 3.2.5 there is a command line interface which can
show you the comparision results for versions given on the command line like
This API is concerned with firing a Maven build in a new JVM. It accomplishes
its task by building up a conventional Maven command line from options given in
the current request, along with those global options specified in the invoker
itself. Once it has the command line, the invoker will execute it, and capture
the resulting exit code or any exception thrown to signal a failure to execute.
Input/output control can be specified using an InputStream and up to two
You can download the appropriate sources etc. from the