Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I can list all sbt dependencies?

Tags:

scala

sbt

I need to list all sbt dependencies in order to check if already exists a debian package (I also notice that there is a DEB package but it seems that external dependencies are not packaged).

At the moment I did a list of sbt dependencies with the following steps:

  1. Install sbt manually

  2. I created a simple script that extract all jar files in ~/.ivi2 directory (excluding sbt jar). Here the result of the execution:

    Group;Artifact;Artifact+Version
    org.scala-lang;jline;jline-2.10.5
    org.scala-lang;scala-compiler;scala-compiler-2.10.5
    org.scala-lang;scala-library;scala-library-2.10.5
    org.scala-lang;scala-reflect;scala-reflect-2.10.5
    com.jcraft;jsch;jsch-0.1.46
    org.scalamacros;quasiquotes_2.10;quasiquotes_2.10-2.0.1
    jline;jline;jline-2.11
    com.thoughtworks.paranamer;paranamer;paranamer-2.6
    org.json4s;json4s-ast_2.10;json4s-ast_2.10-3.2.10
    org.json4s;json4s-core_2.10;json4s-core_2.10-3.2.10
    org.scala-lang.modules;scala-pickling_2.10;scala-pickling_2.10-0.10.0
    org.scala-tools.sbinary;sbinary_2.10;sbinary_2.10-0.4.2
    org.fusesource.jansi;jansi;jansi-1.4
    org.spire-math;json4s-support_2.10;json4s-support_2.10-0.6.0
    org.spire-math;jawn-parser_2.10;jawn-parser_2.10-0.6.0
    

Do you think is the right way to list all sbt dependencies?

like image 790
Fabio Avatar asked Jan 04 '16 00:01

Fabio


People also ask

Where are sbt dependencies stored?

All new SBT versions (after 0.7. x ) by default put the downloaded JARS into the . ivy2 directory in your home directory. If you are using Linux, this is usually /home/<username>/.

What are library dependencies in sbt?

Library dependencies can be added in two ways: unmanaged dependencies are jars dropped into the lib directory. managed dependencies are configured in the build definition and downloaded automatically from repositories.

How do we specify library dependencies in sbt?

You can use both managed and unmanaged dependencies in your SBT projects. 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.


2 Answers

There is a nice sbt plugin for that: https://github.com/jrudolph/sbt-dependency-graph

Simply adding to ~/.sbt/0.13/plugins/plugins.sbt:

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

Calling sbt dependencyTree you can get an "ascii graph" like:

...
[info]   | +-org.apache.lucene:lucene-spatial:4.10.2
[info]   | | +-com.spatial4j:spatial4j:0.4.1
[info]   | | +-org.apache.lucene:lucene-core:4.10.2
[info]   | | +-org.apache.lucene:lucene-queries:4.10.2
[info]   | |   +-org.apache.lucene:lucene-core:4.10.2
[info]   | |
[info]   | +-org.apache.lucene:lucene-suggest:4.10.2
[info]   |   +-org.apache.lucene:lucene-analyzers-common:4.10.2
[info]   |   | +-org.apache.lucene:lucene-core:4.10.2
[info]   |   |
[info]   |   +-org.apache.lucene:lucene-core:4.10.2
[info]   |   +-org.apache.lucene:lucene-misc:4.10.2
[info]   |   | +-org.apache.lucene:lucene-core:4.10.2
[info]   |   |
[info]   |   +-org.apache.lucene:lucene-queries:4.10.2
[info]   |     +-org.apache.lucene:lucene-core:4.10.2
...
like image 179
Filippo Vitale Avatar answered Sep 18 '22 09:09

Filippo Vitale


In case the dependency hierarchy provided by sbt-dependency-graph is not needed, the following might be useful:

sbt 'show dependencyClasspathFiles'
like image 40
pgrandjean Avatar answered Sep 20 '22 09:09

pgrandjean