How to see dependency tree in sbt?

I am trying to show the SBT dependency tree as described in the documentation :

sbt inspect tree clean 

But I get this error:

 [error] inspect usage: [error] inspect [uses|tree|definitions] <key> Prints the value for 'key', the defining scope, delegates, related definitions, and dependencies. [error] [error] inspect [error] ^ 

What's wrong? Why doesn't SBT create a tree?

+49
scala dependencies sbt
Aug 27 '14 at 6:00
source share
3 answers

When launched from the command line, each argument sent to sbt must be a command, so sbt inspect tree clean will be:

  • run the inspect command
  • then run the tree command,
  • then the clean command

This obviously fails, since inspect requires an argument. This will do what you want:

 sbt "inspect tree clean" 
+65
Aug 27 '14 at 6:21
source share

If you want to actually look at library dependencies (as with Maven) and not task dependencies (which is displayed by the inspect tree ), then you will want to use the sbt-dependency-graph plugin.

Add the following to your project /plugins.sbt (or global plugins.sbt).

 addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.8.2") 

Then you have access to the dependencyTree command and others.

+62
May 24 '16 at 13:14
source share

If you want to view library dependencies , you can use the coursier plugin: https://github.com/coursier/coursier#printing-trees

Output Example: image text (without colors): https://gist.github.com/vn971/3086309e5b005576533583915d2fdec4

Please note that the plugin has a completely different character than printing trees. It is designed for fast and parallel dependency loading. But it's nice and can be added to almost any project, so I think it's worth mentioning.

+7
Apr 19 '17 at 10:55 on
source share



All Articles