Instantly share code, notes, and snippets.

Embed
What would you like to do?
dependency-tree for Leiningen
;; requires [com.cemerick/pomegranate "0.0.2"]
;; i.e. https://github.com/cemerick/pomegranate
(use '[cemerick.pomegranate.aether :only (dependency-hierarchy resolve-dependencies)])
=> (pprint
(dependency-hierarchy
'[[incanter "1.2.3"]]
(resolve-dependencies {:coordinates '[[incanter "1.2.3"]]
:repositories (merge cemerick.pomegranate.aether/maven-central {"clojars" "http://clojars.org/repo"})})))
nil
{[incanter "1.2.3"]
{[incanter/incanter-charts "1.2.3"]
{[incanter/jfreechart "1.0.13-no-gnujaxp"]
{[incanter/jcommon "1.0.16"] nil}},
[incanter/incanter-core "1.2.3"]
{[incanter/parallelcolt "0.9.4"]
{[incanter/arpack-combo "0.9.4"] nil,
[incanter/csparsej "0.9.4"] nil,
[incanter/jplasma "0.9.4"] nil,
[incanter/jtransforms "0.9.4"] nil,
[incanter/netlib-java "0.9.4"] nil,
[incanter/optimization "0.9.4"] nil},
[org.clojure/clojure-contrib "1.2.0"] nil,
[org.clojure/clojure "1.2.0"] nil},
[incanter/incanter-excel "1.2.3"]
{[org.apache.poi/poi "3.6"]
{[commons-logging "1.1" :scope "runtime"]
{[avalon-framework "4.1.3" :scope "runtime"] nil,
[javax.servlet/servlet-api "2.3" :scope "runtime"] nil,
[logkit "1.0.1" :scope "runtime"] nil},
[log4j "1.2.13" :scope "runtime"] nil}},
[incanter/incanter-io "1.2.3"]
{[net.sf.opencsv/opencsv "2.0.1"] nil,
[org.danlarkin/clojure-json "1.1-20091229.021828-4"] nil},
[incanter/incanter-latex "1.2.3"]
{[net.sf.alxa/jlatexmath "0.9.1-20100323.073428-1"] nil},
[incanter/incanter-mongodb "1.2.3"]
{[org.clojars.bmabey/congomongo "0.1.2-20100502.112537-2"]
{[org.clojars.somnium/clojure-db-object "0.1.1-20091229.021828-2"]
nil,
[org.clojars.somnium/mongo-java-driver "1.1.0-20091229.021828-3"]
nil}},
[incanter/incanter-pdf "1.2.3"] {[com.lowagie/itext "1.4"] nil},
[incanter/incanter-processing "1.2.3"]
{[incanter/processing-core "1.1"] nil},
[jline "0.9.94"] {[junit "3.8.1"] nil},
[swank-clojure "1.3.0-20110104.084027-21"] nil,
[swingrepl "1.0.0-20100502.112537-4"] nil}}
@samaaron

This comment has been minimized.

samaaron commented Dec 13, 2011

Insanely cool. Out of interest, why the need for the internal call to resolve-dependencies within dependency-hierarchy? It seems strange to see '[[incanter "1.2.3"]] specified twice.

@cemerick

This comment has been minimized.

Owner

cemerick commented Dec 13, 2011

resolve-dependencies returns an unrooted graph; dependency-hierarchy prunes that graph based on one or more roots. In nearly all real-world usage, there will be multiple roots, and it wouldn't be wise IMO to have the dependency graph cart around the roots that were used to produce it.

FWIW, these are low-level functions; in reality, the interaction between them is going to get wrapped up into a helper fn that will make the (apparent) complexity disappear. :-)

@samaaron

This comment has been minimized.

samaaron commented Dec 13, 2011

Interesting. I guess I just need to look into this stuff a little bit closer. Do you have any links that would be useful?

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