Skip to content

Instantly share code, notes, and snippets.

@mslinn
Created July 12, 2012 21:13
Show Gist options
  • Save mslinn/3101038 to your computer and use it in GitHub Desktop.
Save mslinn/3101038 to your computer and use it in GitHub Desktop.
Shows all dependencies of an SBT project
#!/bin/bash
echo "Direct dependencies"
sbt 'show all-dependencies' | \
gawk 'match($0, /List\((.*)\)/, a) {print a[1]}' | \
tr -d ' ' | tr ',' '\n' | sort -t ':' | \
tr ':' '\t' | expand -t 30
echo -e "\nAll dependencies, including transitive dependencies"
sbt 'show managed-classpath' | tr -d ' ' | tr ',' '\n' | \
gawk 'match($0, /Attributed\((.*)\)/, a) {print a[1]}' | \
tr -d '()' | sed "s^$HOME/.ivy2/cache/^^g" | sed "s^/jars^^" | \
gawk -F / '{print $1, $3}' | sort | tr ' ' '\t' | expand -t 30
@mslinn
Copy link
Author

mslinn commented Jul 12, 2012

Sample output

Direct dependencies
ch.qos.logback                logback-classic               1.0.0
com.amazonaws                 aws-java-sdk                  1.1.8
com.google.protobuf           protobuf-java                 2.4.1
com.novus                     salat-core                    1.9.0
com.typesafe.akka             akka-actor                    2.0.1
org.apache.solr               solr-solrj                    3.6.0                         compile
org.scala-lang                scala-library                 2.9.1

All dependencies, including transitive dependencies
ch.qos.logback                logback-classic-1.0.0.jar
ch.qos.logback                logback-core-1.0.0.jar
com.amazonaws                 aws-java-sdk-1.1.8.jar
com.google.protobuf           protobuf-java-2.4.1.jar
commons-codec                 commons-codec-1.6.jar
commons-httpclient            commons-httpclient-3.1.jar
commons-io                    commons-io-2.1.jar
commons-logging               commons-logging-1.1.1.jar
com.novus                     salat-core_2.9.1-1.9.0.jar
com.novus                     salat-util_2.9.1-1.9.0.jar
com.thoughtworks.paranamer    paranamer-2.4.1.jar
com.typesafe.akka             akka-actor-2.0.1.jar
javax.activation              activation-1.1.jar
javax.mail                    mail-1.4.5.jar
joda-time                     joda-time-1.6.2.jar
net.liftweb                   lift-json_2.9.1-2.5-SNAPSHOT.jar
org.apache.solr               solr-solrj-3.6.0.jar
org.codehaus.jackson          jackson-core-asl-1.9.8.jar
org.codehaus.woodstox         wstx-asl-3.2.7.jar
org.mongodb                   casbah-commons_2.9.1-2.4.1.jar
org.mongodb                   casbah-core_2.9.1-2.4.1.jar
org.mongodb                   casbah-gridfs_2.9.1-2.4.1.jar
org.mongodb                   casbah-query_2.9.1-2.4.1.jar
org.mongodb                   casbah-util_2.9.1-2.4.1.jar
org.mongodb                   mongo-java-driver-2.8.0.jar
org.scalaj                    scalaj-collection_2.9.1-1.2.jar
org.scala-lang                scalap-2.9.1.jar
org.scala-tools.time          time_2.9.1-0.5.jar
org.slf4j                     jcl-over-slf4j-1.6.1.jar
org.slf4j                     slf4j-api-1.6.4.jar
org.specs2                    specs2_2.9.1-1.7.1.jar
org.specs2                    specs2-scalaz-core_2.9.1-6.0.1.jar
stax                          stax-api-1.0.1.jar

@mslinn
Copy link
Author

mslinn commented Aug 3, 2012

The dependencReport SBT plug-in works better, because it also displays transitive dependencies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment