On Fri, 16 Dec 2016 17:25:16 +0100, Christian Schulte <c...@schulte.it> wrote:

Am 12/16/16 um 15:21 schrieb Robert Scholte:

but this cover the issue we are talking about, because IIUC you are saying that IF both junit and hamcrest get the test-scope AND hamcrest would have
a dependency THEN that dependency is not added to the classpath. That is
still unexpected behavior.

Just add 'test' scope to the hamcrest dependency in that pom. It will
disappear from the classpath. I would expect that to happen. Why should
it manage the version but not the scope?


Because Junit refers to hamcrest classes, so they are required to be able to compile. There is an issue about this, that Maven should never reduce the scope. Suppose the user wasn't aware that hamcrest is a runtime requirement of JUnit and simply adds it for his own test there as test-scoped dependency you will have a surprising effect. I am of course aware that (currently) a dependency can only have one version and one scope. However, I would love to go for a different approach: choose one or more scopes and select all their matching dependencies + transitive dependencies. Reflecting this to your example hamcrest would always be selected as transitive dependency of junit and its scope will be ignored. This matches much better the real world expected behavior no matter what the Maven documentation says.

Btw, this looks very close to https://issues.apache.org/jira/browse/MNG-6058

Robert


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org

Reply via email to