If we consider the following example, what is the difference between "+-" and "\-" symbols and what do they signify?
[INFO] [dependency:tree] [INFO] org.apache.maven.plugins:maven-dependency-plugin:maven-plugin:2.0-alpha-5-SNAPSHOT [INFO] +- org.apache.maven.reporting:maven-reporting-impl:jar:2.0.4:compile [INFO] | \- commons-validator:commons-validator:jar:1.2.0:compile [INFO] | \- commons-digester:commons-digester:jar:1.6:compile [INFO] | \- (commons-collections:commons-collections:jar:2.1:compile - omitted for conflict with 2.0) [INFO] \- org.apache.maven.doxia:doxia-site-renderer:jar:1.0-alpha-8:compile [INFO] \- org.codehaus.plexus:plexus-velocity:jar:1.1.3:compile [INFO] \- commons-collections:commons-collections:jar:2.0:compile
A project's dependency tree can be filtered to locate specific dependencies. For example, to find out why Velocity is being used by the Maven Dependency Plugin, we can execute the following in the project's directory: mvn dependency:tree -Dincludes=velocity:velocity.
How to get the Maven Dependency Tree of a Project. We can run mvn dependency:tree command in the terminal to print the project dependency tree. For our example, I will be using the Mockito Tutorial project. You can download the project from the GitHub repository.
mvn dependency:tree CommandThe main purpose of the dependency:tree goal is to display in form of a tree view all the dependencies of a given project. As we can see, maven prints the dependencies tree of our project.
Those symbols do not have any meaning whatsoever, they are just present to read the output of the tree better!
Here's a more complex output to see better what it does, on a spring-webmvc
dependency:
[INFO] +- org.springframework:spring-webmvc:jar:4.2.2.RELEASE:compile [INFO] | +- org.springframework:spring-beans:jar:4.2.2.RELEASE:compile [INFO] | +- org.springframework:spring-context:jar:4.2.2.RELEASE:compile [INFO] | | \- org.springframework:spring-aop:jar:4.2.2.RELEASE:compile [INFO] | | \- aopalliance:aopalliance:jar:1.0:compile [INFO] | +- org.springframework:spring-core:jar:4.2.2.RELEASE:compile [INFO] | | \- commons-logging:commons-logging:jar:1.2:compile [INFO] | +- org.springframework:spring-expression:jar:4.2.2.RELEASE:compile
Consider the dependency tree as levels: the first level correspond to the direct dependencies; the second level corresponds to the transitive dependencies of those direct dependencies, etc.
Basically, if there is more than one dependency on the same level for the same artifact, a +-
will be shown, otherwise a \-
will be shown, indicating an "end" of the tree (i.e. a path leading to a leaf).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With