Maven resolves version ranges in ways you might find strange...

IF AND ONLY IF you have followed the Maven Version Number format

[Major].[Minor].[Update]-[Build/Classifier]

THEN version ranges will resolve somewhat sensibly.

If you have a version number that is not in the magic format, then
version comparison falls back to
v1.toString().compareTo(v2.toString())

So

5.0.0.0 < 1.0 < 1.0.1 < 1.0.1-1 < 2 < 3.0 < 4.5.7-6 < 5.0.0

Fun eh!

So if you stick to Maven's format, then

[1.0.0,2.0.0-SNAPSHOT)

will resolve any 1.x version... there is some trickery about whether
to include the -SNAPSHOT or not to do with ensuring that the snapshot
does not get pulled in, e.g.
2.0.0-SNAPSHOT < 2.0.0
But then IIRC if you include a SNAPSHOT in the range in some versions
of Maven, then the range allows resolving -SNAPSHOTs

Most people don't use Ranges.... which is why they have not felt the love.

The current preference is to use locked down versions in your pom and
have e.g. the versions-maven-plugin do the updating....

Though I have to give the versions-maven-plugin some love once I get
some other tasks off my plate

-Stephen

On 13 April 2011 07:41, Tom <[email protected]> wrote:
>  Maven resolves dependencies under the (rightful) assumption that a higher
> version is 100% backwards compatible to an earlier release, and therefor
> picks the highest requires version of a dependency. But once every so often
> a library should be purged, things cannot be @depricated forever.
>
> Is it possible to tell Maven a library is not backwards compatible anymore?
>
> I usually use a major version increment for such steps (e.g. 1.x becomes
> 2.x). But even specifying ranges "[1.0,1.999]" combined with "[2.0,2.999]"
> do not cause an error of some kind, but simply resolve to 2.x.
>
> Kind regards,
>
> Tom
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to