[logback-dev] Expanding version99 repository

Robert Elliot rob at lidalia.org.uk
Fri Aug 3 14:20:59 CEST 2012

> > For
> > example, if you want to use hamcrest 1.3 with junit 4.10 you can do
> > so
> > by bringing in junit:junit-dep:4.10 and
> > org.hamcrest:hamcrest-core:1.3; however, it only requires one
> > transitive dependency to bring in junit:junit:4.7 (which combines
> > the
> > classes from junit:junit-dep:4.7 and org.hamcrest:hamcrest-core:1.2)
> > and it's going to be random whether you get the 4.10 or the 4.7
> > versions of the junit classes and the 1.2 or 1.3 versions of the
> > hamcrest classes.
> While I understand what you are trying to explain I don't see how it
> matches what is effectively found in junit jar files. For example,
> both junit:junit:4.7 and 4.10 contain classes from the org.hamcrest
> package. What am I missing?

There are three artifacts in Maven, and as far as Maven is concerned they are unconnected, so they can coexist on the same classpath:
org.hamcrest:hamcrest-core  // Contains just the Hamcrest core classes
junit:junit-dep             // Contains just the JUnit classes with no Hamcrest ones
junit:junit                 // Contains both the JUnit and the Hamcrest core classes

If, thanks to transitive dependencies, you end up with both junit:junit:4.7 and junit:junit-dep:4.10 on the classpath, with different versions, there will be different versions of the same org.junit classes on the classpath, with no guaranteed as to which will be loaded.

The same holds true if you have org.hamcrest:hamcrest-core:1.3 and junit:junit:4.10 on the classpath - different versions of the same org.hamcrest classes on the same classpath, with no guaranteed as to which will be loaded.

More information about the logback-dev mailing list