You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Jörg Wille <jo...@gmail.com> on 2017/04/21 23:18:46 UTC

understanding maven version resolution: minor and snapshots

In a project 2 "different" versions of the same library A are used. One, as
a direct dependency with a snapshot version *3.2.1-SNAPSHOT* and the same
library - but with version *3.2.0* -  is being used as a transient
dependency in yet another library B. So, the 2 dependencies of A only
differ in the minor version.
When I build/install this project only the 3.2.1-SNAPSHOT version of
library A gets downloaded.
Is this correct behaviour for maven since it evaluates the 3.2.1-SNAPSHOT
to be compatible with the 3.2.0 release version or should maven download
the 3.2.0 release version since it is explicit mentioned as a transient
dependency in the pom of a  library B?

Re: understanding maven version resolution: minor and snapshots

Posted by Erik Bertelsen <be...@gmail.com>.
Also:

The command
   mvn dependency:tree

may be your rescue, look for entries marked as conflicting.

- Erik

2017-04-22 9:31 GMT+02:00 Anders Hammar <an...@hammar.net>:
>> Nope it pick the *nearest* version.
>>
>
>> Direct dependency trumps transitive
>>
>
> And to give the full picture, if different versions are declared at the
> same level in the dependency tree (typically via transitive dependencies
> when you don't have a direct dep), the first declaration wins. So, the
> order you declare your dependencies could actually have an impact in that
> case.
>
> /Anders
>
>
>>
>> >
>> >
>> > Regards,
>> > Curtis
>> >
>> > --
>> > Curtis Rueden
>> > LOCI software architect - https://loci.wisc.edu/software
>> > ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
>> >
>> >
>> > On Fri, Apr 21, 2017 at 6:18 PM, Jörg Wille <jo...@gmail.com>
>> wrote:
>> >
>> > > In a project 2 "different" versions of the same library A are used.
>> One,
>> > as
>> > > a direct dependency with a snapshot version *3.2.1-SNAPSHOT* and the
>> same
>> > > library - but with version *3.2.0* -  is being used as a transient
>> > > dependency in yet another library B. So, the 2 dependencies of A only
>> > > differ in the minor version.
>> > > When I build/install this project only the 3.2.1-SNAPSHOT version of
>> > > library A gets downloaded.
>> > > Is this correct behaviour for maven since it evaluates the
>> 3.2.1-SNAPSHOT
>> > > to be compatible with the 3.2.0 release version or should maven
>> download
>> > > the 3.2.0 release version since it is explicit mentioned as a transient
>> > > dependency in the pom of a  library B?
>> > >
>> >
>> --
>> Sent from my phone
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: understanding maven version resolution: minor and snapshots

Posted by Anders Hammar <an...@hammar.net>.
> Nope it pick the *nearest* version.
>

> Direct dependency trumps transitive
>

And to give the full picture, if different versions are declared at the
same level in the dependency tree (typically via transitive dependencies
when you don't have a direct dep), the first declaration wins. So, the
order you declare your dependencies could actually have an impact in that
case.

/Anders


>
> >
> >
> > Regards,
> > Curtis
> >
> > --
> > Curtis Rueden
> > LOCI software architect - https://loci.wisc.edu/software
> > ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
> >
> >
> > On Fri, Apr 21, 2017 at 6:18 PM, Jörg Wille <jo...@gmail.com>
> wrote:
> >
> > > In a project 2 "different" versions of the same library A are used.
> One,
> > as
> > > a direct dependency with a snapshot version *3.2.1-SNAPSHOT* and the
> same
> > > library - but with version *3.2.0* -  is being used as a transient
> > > dependency in yet another library B. So, the 2 dependencies of A only
> > > differ in the minor version.
> > > When I build/install this project only the 3.2.1-SNAPSHOT version of
> > > library A gets downloaded.
> > > Is this correct behaviour for maven since it evaluates the
> 3.2.1-SNAPSHOT
> > > to be compatible with the 3.2.0 release version or should maven
> download
> > > the 3.2.0 release version since it is explicit mentioned as a transient
> > > dependency in the pom of a  library B?
> > >
> >
> --
> Sent from my phone
>

Re: understanding maven version resolution: minor and snapshots

Posted by Stephen Connolly <st...@gmail.com>.
On Sat 22 Apr 2017 at 00:21, Curtis Rueden <ct...@wisc.edu> wrote:

> Hi Jörg,
>
> As far as I know, Maven has no notion of "major" vs. "minor" vs. "patch"
> versions in the style of e.g. SemVer.
>
> It simply judges which version is the newest via its algorithm, and uses
> the newest, since it is assumed that a dependency on e.g. 3.2.0 means
> "version must be at least as new as 3.2.0".


Nope it pick the *nearest* version.

Direct dependency trumps transitive

>
>
> Regards,
> Curtis
>
> --
> Curtis Rueden
> LOCI software architect - https://loci.wisc.edu/software
> ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
>
>
> On Fri, Apr 21, 2017 at 6:18 PM, Jörg Wille <jo...@gmail.com> wrote:
>
> > In a project 2 "different" versions of the same library A are used. One,
> as
> > a direct dependency with a snapshot version *3.2.1-SNAPSHOT* and the same
> > library - but with version *3.2.0* -  is being used as a transient
> > dependency in yet another library B. So, the 2 dependencies of A only
> > differ in the minor version.
> > When I build/install this project only the 3.2.1-SNAPSHOT version of
> > library A gets downloaded.
> > Is this correct behaviour for maven since it evaluates the 3.2.1-SNAPSHOT
> > to be compatible with the 3.2.0 release version or should maven download
> > the 3.2.0 release version since it is explicit mentioned as a transient
> > dependency in the pom of a  library B?
> >
>
-- 
Sent from my phone

Re: understanding maven version resolution: minor and snapshots

Posted by Curtis Rueden <ct...@wisc.edu>.
Hi Jörg,

As far as I know, Maven has no notion of "major" vs. "minor" vs. "patch"
versions in the style of e.g. SemVer.

It simply judges which version is the newest via its algorithm, and uses
the newest, since it is assumed that a dependency on e.g. 3.2.0 means
"version must be at least as new as 3.2.0".

Regards,
Curtis

--
Curtis Rueden
LOCI software architect - https://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden


On Fri, Apr 21, 2017 at 6:18 PM, Jörg Wille <jo...@gmail.com> wrote:

> In a project 2 "different" versions of the same library A are used. One, as
> a direct dependency with a snapshot version *3.2.1-SNAPSHOT* and the same
> library - but with version *3.2.0* -  is being used as a transient
> dependency in yet another library B. So, the 2 dependencies of A only
> differ in the minor version.
> When I build/install this project only the 3.2.1-SNAPSHOT version of
> library A gets downloaded.
> Is this correct behaviour for maven since it evaluates the 3.2.1-SNAPSHOT
> to be compatible with the 3.2.0 release version or should maven download
> the 3.2.0 release version since it is explicit mentioned as a transient
> dependency in the pom of a  library B?
>