Robert Scholte wrote:
> You're hitting MNG-5739
> 
> Within a dependency-tree a groupId+artifactId is unique (nearest wins).
> Such a dependency has 1 version, but also 1 scope.
> By setting it explicit to test, you reduce the scope and it is not
> available during compile anymore.
> 
> Is this correct?

Yes, this is what I observe.

> Well, this concept ensures that you test with exactly the same set of
> dependencies as the ones available at runtime.

That's a reasonable goal; you wouldn't want to use different versions
between in compile and test classpath.

> On the other hand, reducing the scope implies that you'll be missing one
> or more dependencies at runtime.
> 
> We could think of making dependencies *always* scope-context-aware.
> Using your case one could suggest that at compile-time hamcrest-core:1.1
> is used, but at test-time hamcrest-core:1.2

I don't think that's a good solution, as it misses the goal of using the
*same* version of a library in compile and test classpaths.

IMHO, the better solution would be if the direct, test-scoped
hamcrest-core:1.2 dependency promoted the transitive, compile-scoped
hamcrest-core:1.1 to version 1.2 -- even if it itself were excluded from
the compile classpath.

Granted, this would mean that one part of the dependency graph overrides
versions in another part of the graph, which seems unexpected, but with
dependencies being "omitted for conflict" we already have something similar.

> To me this makes more sense, but at the same time it is hard to predict
> the impact of such a change.

That being said, I can understand when you don't want to change this
behavior, as that would potentially change the meaning of existing POMs.
However, it would only *add* compile-scoped dependencies that weren't
there previously, so I think the change wouldn't break anything but
merely add dependencies to the classpath that logically should have been
there all along -- but whose absence just didn't cause any compilation
or runtime error.

Best wishes,

Andreas

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to