In the maven dependency tree does the parent dependency override the scope of the child?

Metin Dagcilar :

If i have the following output from running mvn dependency:tree are the jars that are brought in test or compile scope?

[INFO] |  +- io.springfox:springfox-swagger1:jar:2.5.0:test
[INFO] |  |  +- io.springfox:springfox-schema:jar:2.5.0:compile
[INFO] |  |  +- io.springfox:springfox-swagger-common:jar:2.5.0:compile
Karol Dowbecki :

In your example all three dependencies are effectively test scoped. As per Dependency Scope docs any transitive compile scoped dependency of a test scoped dependency becomes test scope:

Each of the scopes (except for import) affects transitive dependencies in different ways, as is demonstrated in the table below. If a dependency is set to the scope in the left column, transitive dependencies of that dependency with the scope across the top row will result in a dependency in the main project with the scope listed at the intersection. If no scope is listed, it means the dependency will be omitted.

            compile     provided        runtime     test
compile     compile     -               runtime     -
provided    provided    -               provided    -
runtime     runtime     -               runtime     -
test        test        -               test        -

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=86756&siteId=1
Recommended