SBT-dependency tree


In this blog , I am going to describe how to view sbt dependency tree.  Last week I had a problem related to different cross version of a dependency. I knew the problem cause but  I had spent a day to know which dependency had brought that cross version of dependency. I did some study and browsing about that problem then I come across a sbt plugins as a potential solution of that problem.
In a project there is a chance of using same library but different version by multiple dependencies.  I also victim of dependency version conflict.  The good way is just draw a sbt dependency tree. Here is a sbt-plugin sbt-dependency graph is available for that.

Following are the steps to install and use sbt-dependency-graph
a) add plugin to project/plugins.sbt

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

b) add sbt setting in build.sbt

net.virtualvoid.sbt.graph.Plugin.graphSettings

if project is multi module then add to Parent.scala:

object Parent extends Build{
lazy val parent = Project(id="parent", base=file(".")).settings(net.virtualvoid.sbt.graph.Plugin.graphSettings: _*)
}

Now run sbt commond:

$ sbt dependency-tree
+-org.jsoup:jsoup:0.2.2
[info]   | +-commons-lang:commons-lang:2.4
[info]   |
[info]   +-org.scala-lang:scala-library:2.11.0 (evicted by: 2.11.2)
[info]   +-org.scala-lang:scala-library:2.11.1 (evicted by: 2.11.2)
[info]   +-org.scalaz:scalaz-core_2.11:7.0.6 [S]
[info]     +-org.scala-lang.modules:scala-parser-combinators_2.11:1.0.1 [S]
[info]     | +-org.scala-lang:scala-library:2.11.0 (evicted by: 2.11.2)
[info]     | +-org.scala-lang:scala-library:2.11.1 (evicted by: 2.11.2)
[info]     |
[info]     +-org.scala-lang.modules:scala-xml_2.11:1.0.1 (evicted by: 1.0.2)
[info]     +-org.scala-lang.modules:scala-xml_2.11:1.0.2 [S]
[info]     | +-org.scala-lang:scala-library:2.11.0 (evicted by: 2.11.2)
[info]     | +-org.scala-lang:scala-library:2.11.1 (evicted by: 2.11.2)
[info]     |
[info]     +-org.scala-lang:scala-library:2.11.0 (evicted by: 2.11.2)

or 

$ sbt dependency-graph

or provide lot of options.for more info sbt-dependency-graph

Enjoy with  sbt  projects !!!

About Satendra Kumar

Satendra kumar is the Senior Associate @ Sapient Global Market. In his 5 years of experience he has become developer with proven experience in architecting and developing the Reactive Systems and Big Data Platform with Scala, Akka, Spark, Kafka & Hadoop. He is the big fan of Scala. Satendra has a B.Tech in Computer Engineering from Uttar Pradesh Technical University.
This entry was posted in Scala. Bookmark the permalink.

One Response to SBT-dependency tree

  1. adamw1pl says:

    If you’d like to get a graphical, searchable representation of the dependency tree (including all modules from your project, transitive dependencies and eviction information), check out UpdateImpact: https://app.updateimpact.com (free service).

    _Disclaimer: I’m one of the developers of the site_

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s