I know Maven version management can be, ah, challenging, so I stick to Maven 
compatible versioning. Maybe not to the deepest level (1.0.0-b01), but surely 
in a very common accepted style (1.0). I am not having any problems with Maven 
using the wrong versions.

My question is with how to tell Maven two releases are no longer compatible. So if one 
dependency uses 1.x and the other uses 2.x, and 2.x is "declared" not backwards 
compatible to 1.x, then Maven should either:
1. report a build error on a version conflict
2. or include both versions of the artifact.

Tom



On 13-4-2011 10:56, Stephen Connolly wrote:
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]




--

*Tom Eugelink*
Senior software engineer
+31 (0)6 - 47 93 85 92
[email protected] <mailto:[email protected]>
        *KnowledgePlaza <http://www.knowledgeplaza.nl>*
Sutton 15
7327 AB Apeldoorn
Tel: +31 (0)55 - 526 3887
Fax: +31 (0)55 - 526 3950
[email protected] <mailto:[email protected]>
Disclaimer: The information contained in this message is for the intended 
addressee only and may contain confidential and/or privileged information. If 
you are not the intended addressee, please delete this message and notify the 
sender; do not copy or distribute this message or disclose its contents to 
anyone.








Reply via email to