What is the difference between "+-" and "\-" in maven dependency tree output?
Asked Answered
S

5

42

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
Subfusc answered 30/11, 2015 at 19:48 Comment(1)
It has no Maven or Dependency specific significance. It's just ascii art: the + is there because there's a line going to the right and a line going down. The \- is an attempt at a 90 degree angle: a line going to the right (and no more lines below it). See this question for some more examples.Danielson
C
50

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).

Cobnut answered 30/11, 2015 at 19:53 Comment(1)
Maybe it's because the Maven team cannot output and with ascii.. so they chose +- and \-, but seems a little bit confusing nowadays, at least for me.Weihs
D
33

The \- symbol indicates that this node is the last sibling listed for the current parent

Diarchy answered 22/1, 2016 at 18:36 Comment(0)
B
8

The plus symbol indicates several nodes on the same level, while the - symbol indicates one single node for that level of hierarchy.

Hence, in your case, maven-dependency-plugin (+ symbol) has as transitive dependencies maven-reporting-impl and doxia-site-renderer at first level, then maven-reporting-impl only has (- symbol) commons-validator as direct transitive dependency and so on.

Braided answered 30/11, 2015 at 19:53 Comment(0)
P
0

For multiple dependencies on the same level, \- will be shown for the last dependency at that level and +- will be shown for all the other dependencies at that level.

Patrizia answered 21/7, 2021 at 19:4 Comment(1)
Does this somehow enhance the already given answers?Niels
I
0

Maybe "+-" means the non-last node in the tree hierarchy

"\-" means the last node in the tree hierarchy

I guess that he may use some kind of data structure whose tail is an index.

for example

root:
....+-(first chirld)
....+-(second chirld)
........\-(last chirld)
....\-(last chirld)

Here's a more complex output about [maven-dependency-tree][https://github.com/apache/maven-dependency-tree] dependency:

[INFO] Scanning for projects...
[INFO]
[INFO] -----------< org.apache.maven.shared:maven-dependency-tree >------------
[INFO] Building Apache Maven Dependency Tree 3.1.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:3.1.1:tree (default-cli) @ maven-dependency-tree ---
[INFO] org.apache.maven.shared:maven-dependency-tree:jar:3.1.1-SNAPSHOT
[INFO] +- org.apache.maven:maven-core:jar:3.0.5:compile
[INFO] |  +- org.apache.maven:maven-model:jar:3.0.5:compile
[INFO] |  +- org.apache.maven:maven-settings:jar:3.0.5:compile
[INFO] |  +- org.apache.maven:maven-settings-builder:jar:3.0.5:compile
[INFO] |  +- org.apache.maven:maven-repository-metadata:jar:3.0.5:compile
[INFO] |  +- org.apache.maven:maven-artifact:jar:3.0.5:compile
[INFO] |  +- org.apache.maven:maven-plugin-api:jar:3.0.5:compile
[INFO] |  +- org.apache.maven:maven-model-builder:jar:3.0.5:compile
[INFO] |  +- org.apache.maven:maven-aether-provider:jar:3.0.5:compile
[INFO] |  |  \- org.sonatype.aether:aether-spi:jar:1.13.1:compile
[INFO] |  +- org.sonatype.aether:aether-impl:jar:1.13.1:compile
[INFO] |  +- org.sonatype.aether:aether-util:jar:1.13.1:compile
[INFO] |  +- org.sonatype.sisu:sisu-inject-plexus:jar:2.3.0:compile
[INFO] |  |  \- org.sonatype.sisu:sisu-inject-bean:jar:2.3.0:compile
[INFO] |  |     \- org.sonatype.sisu:sisu-guice:jar:no_aop:3.1.0:compile
[INFO] |  |        \- org.sonatype.sisu:sisu-guava:jar:0.9.9:compile
[INFO] |  +- org.codehaus.plexus:plexus-interpolation:jar:1.14:compile
[INFO] |  +- org.codehaus.plexus:plexus-utils:jar:2.0.6:compile
[INFO] |  +- org.codehaus.plexus:plexus-classworlds:jar:2.4:compile
[INFO] |  \- org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3:compile
[INFO] |     \- org.sonatype.plexus:plexus-cipher:jar:1.4:compile
[INFO] +- org.codehaus.plexus:plexus-component-annotations:jar:2.0.0:compile (optional)
[INFO] +- org.sonatype.aether:aether-api:jar:1.13.1:compile (optional)
[INFO] +- org.eclipse.aether:aether-api:jar:1.1.0:compile (optional)
[INFO] \- org.eclipse.aether:aether-util:jar:1.1.0:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.519 s
[INFO] Finished at: 2021-12-27T16:06:44+08:00
[INFO] ------------------------------------------------------------------------

Incombustible answered 27/12, 2021 at 8:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.