Visualizing Project Dependencies in Sbt

For pretty printing dependencies in sbt, use sbt-dependency-graph plugin. To use this plugin, add sbt plugin settings:

build/plugins.sbt
1
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.4")

Next update the settings as follows (append graphSettings to every poject):

project/Build.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import sbt._
import Keys._

object MyBuild extends Build {

    private val commonSettings = net.virtualvoid.sbt.graph.Plugin.graphSettings

    lazy val root = project
       .in(file("."))
       .settings(commonSettings:_*)
       .aggregate(core, util)

    lazy val core = project
      .settings(commonSettings:_*)
      .settings(
        libraryDependencies += "org.fluentd" % "fluent-logger" % "0.2.10"
      )

    lazy val util = project
      .settings(commonSettings:_*)

}

Then you can see the detailed dependency graph with dependenty-tree command:

1
2
3
4
5
6
7
8
9
10
11
12
> project core
[info] Set current project to core (in build file:/Users/leo/work/tmp/mproj/)
> dependency-tree
[info] core:core_2.10:0.1-SNAPSHOT [S]
[info]   +-org.fluentd:fluent-logger:0.2.10
[info]     +-org.msgpack:msgpack:0.6.7
[info]       +-com.googlecode.json-simple:json-simple:1.1.1
[info]       | +-junit:junit:4.10
[info]       |   +-org.hamcrest:hamcrest-core:1.1
[info]       |
[info]       +-org.javassist:javassist:3.16.1-GA
[info]

Comments