Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see dependency tree in sbt?

I am trying to inspect 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 is wrong? Why doesn't SBT build the tree?

like image 378
Cherry Avatar asked Aug 27 '14 06:08

Cherry


People also ask

Where are sbt dependencies?

If you have JAR files (unmanaged dependencies) that you want to use in your project, simply copy them to the lib folder in the root directory of your SBT project, and SBT will find them automatically.

What is sbt dependency?

As the SBT documentation states, this means that the dependency you're defining “will be added to the classpath only for the 'Test' configuration, and won't be added in the Compile configuration.” This is useful for adding dependencies like ScalaTest, specs2, Mockito, etc., that will be used when you want to test your ...

How do we specify library dependencies in sbt?

The libraryDependencies key Most of the time, you can simply list your dependencies in the setting libraryDependencies . It's also possible to write a Maven POM file or Ivy configuration file to externally configure your dependencies, and have sbt use those external configuration files.

What is Ivy in sbt?

sbt (through Ivy) verifies the checksums of downloaded files by default. It also publishes checksums of artifacts by default. The checksums to use are specified by the checksums setting.


2 Answers

If you want to actually view the library dependencies (as you would with Maven) rather than the task dependencies (which is what inspect tree displays), then you'll want to use the sbt-dependency-graph plugin.

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

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

Then you have access to the dependencyTree command, and others.

like image 167
OrangeDog Avatar answered Nov 20 '22 23:11

OrangeDog


When run from the command line, each argument sent to sbt is supposed to be a command, so sbt inspect tree cleanwill:

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

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

sbt "inspect tree clean"
like image 20
gourlaysama Avatar answered Nov 20 '22 23:11

gourlaysama