So when I have a pom with <version>1.0</version> that is the strongest hint
for that pom. That version will be used in that pom even if a transitive
dependency has <version>2.0</version>

So one solution to that is to use ranges... if the transitive dependency
has a version like <version>[2.0]</version> then that basically says I must
have version 2.0 nothing else will do. Now my local pom has just a hint of
1.0... but hints can be ignored, so in that case Maven should give my local
pom 2.0 because of the hard dependency in the transitive pom.

Of course such a hard dependency can cause issues... which can then only be
resolved by exclusions and adding back in again

So better is to use ranges, you can have the transitive dependency with a
version like <version>[2.0,3.0)</version> and perhaps another dependency
brings it in with a version like <version>[2.1,4.0)</version>

So in that case we have a local hint of 1.0, and two hard requirements.
Maven is supposed to then resolve that set and come back with an effective
range of [2.1,3.0) now at this point the spec and bugs get imprecise...
there is a bug whereby -SNAPSHOT versions are considered part of the range
(which should IIRC only be the case where at least one bound is a
-SNAPSHOT) and then it is unclear as to whether the top or bottom end of
the range is selected.... if somewhere else in our transitive dependencies,
somebody else has put a hint of 2.2 then because that hint is within the
range it might legitimately be considered a valid hint... though if there
are conflicting hints you then get into topological sorting for distance...
and wahhh

So people don't use ranges and just use hints

On 4 July 2016 at 21:37, Stephen Connolly <[email protected]>
wrote:

> 1.0 is just a hint, hints can be overridden
> [1.0] is a hard requirement
>
> On 4 July 2016 at 21:35, Christian Schulte <[email protected]> wrote:
>
>> Hi,
>>
>> is version "1.0" really different to the version range "[1.0]"? I am
>> asking because I would like to understand what MNG-4883 is about. If you
>> download the attached 'maven-samples.zip' of that issue and build it,
>> Maven will fail due to "overconstraint version ranges". If you take a
>> look at the POMs of the example, they use version ranges as shown above.
>> If you change all those ranges to non-ranges (that is "[1.0]" to "1.0")
>> Maven no longer fails. So I would like to know what the difference is.
>>
>> Regards,
>> --
>> Christian
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>

Reply via email to