Reputation: 155
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:
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?
Upvotes: 15
Views: 15538
Reputation: 173
Just adding here how to install sbt-dependency-graph, I think that is relevant for the question.
IMPORTANT:
The answer is just the part related to sbt-dependency-graph. The complete answer (sbt+scala+homebrew+plugin) you may find here
In order to use the Snyk CLI to test Scala projects, you will need to install the Sbt dependency graph plugin.
Installing the Sbt dependency graph plugin for sbt 0.13 Prerequisites
Ensure you have installed Scala.
Ensure you have installed Sbt and ran sbt.
NOTE: The steps below will install the Sbt dependency plugin as a global plugin.
First navigate to the correct directory by typing the following
command: cd ~/.sbt
This will take you to the Sbt directory. From there you will need to
navigate to the 0.13 directory. Typing the ls
command will show if
0.13 and/or 1.0 exists in the directory
Navigate to 0.13 by typing: cd 0.13
and then make a directory called
plugins by typing: mkdir plugins
Navigate to the new directory by typing: cd plugins
and then proceed
to create a file called “plugins.sbt” by typing: touch plugins.sbt
Edit the plugins.sbt file via your preferred editor
Add the following line to the file:
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.10.0-RC1")
save the changes
Take the following steps for the 1.0 directory. Check if 1.0 exists
by typing ls
in the sbt directory:
If the 1.0 does NOT exist in the sbt directory, type mkdir 1.0
in the sbt directory
If 1.0 exists in the directory, run the following command: cd ~/.sbt/1.0
Make a directory called “plugins” in that folder by typing: mkdir plugins
Copy the existing “plugins.sbt” file from the 0.13 directory to the current 1.0 directory by typing the following: cp ../0.13/plugins/plugins.sbt ./plugins
Validate that the plugin has been installed correctly by running the following command: sbt "-Dsbt.log.noformat=true" dependencyTree
important This should be tested in the directory of the project and by running the command will generate the dependency graph. You can also run it each time you want to generate the dependency graph)
Upvotes: 1
Reputation: 766
In case the dependency hierarchy provided by sbt-dependency-graph
is not needed, the following might be useful:
sbt 'show dependencyClasspathFiles'
Upvotes: 10
Reputation: 8103
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
...
Upvotes: 19