How I can list all sbt dependencies?

2020-07-08 07:18发布

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?

标签: scala sbt
2条回答
家丑人穷心不美
2楼-- · 2020-07-08 07:27

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
...
查看更多
干净又极端
3楼-- · 2020-07-08 07:48

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

sbt 'show dependencyClasspathFiles'
查看更多
登录 后发表回答