This is an interesting state of affairs in Maven that I didn't expect. Maybe someone can explain exactly why this is happening.
I have a parent POM foobar-parent
that declares logback-classic
with a test
scope in the <dependencyManagement>
section.
I have a separate project project example
that has its own example-parent
, which inherits from foobar-parent
and also serves as a parent to its submodules.
One submodule example-foo
overrides the dependency logback-classic
and gives it compile
scope:
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>compile</scope>
</dependency>
Lastly I have another submodule example-bar
which uses example-foo
as a dependency.
Strangely, for the effective POM of example-bar
, it shows that logback-classic
has test
scope!! Since example-foo
declares logback-classic
to be of compile
scope (meaning it is required at compile time), and since example-bar
has a compile-time dependency to example-foo
, I expected example-bar
to bring in logback-classic
as a transitive dependency.
The way I interpret this is that the test
scope specified in the <dependencyManagement>
management section of a parent POM will override the scope of a transitive dependency from the compile
scope!! Is this a correct interpretation, and is that how Maven is supposed to work?