George
George

Reputation: 7317

Confusion surrounding lein :dependencies and :plugins

In a project.clj, when you see things like:

:dependencies [[org.clojure/clojure       "1.8.0"]
               [org.clojure/clojurescript "1.7.228"]
               [com.cemerick/piggieback "0.2.1"]
               [org.clojure/tools.nrepl "0.2.10"]
               [org.clojure/core.async "0.2.374"]]

and:

:plugins [[org.bodil/lein-noderepl "0.1.11"]
          [lein-cljsbuild           "1.1.2"]
          [lein-npm                 "0.6.1"]
          [lein-repls               "1.9.5"]
          [lein-doo                 "0.1.6"]]
  1. Where are these packages coming from? Is it solely Clojars and Maven? Can Lein be configured to get them from GitHub as well?
  2. When these packages are added to your project, is lein merely downloading them and adding them to your java class path? Or something else happening as well?

Upvotes: 3

Views: 478

Answers (1)

Daniel Compton
Daniel Compton

Reputation: 14559

  1. Where are these packages coming from?

is answered well by What are the leiningen default repositories?

You can use something like lein-git-deps to download dependencies from GitHub, but I would recommend using Maven repos, as this is what the Leiningen ecosystem is built around.

  1. Is lein merely downloading them and adding them to your java class path? Or is something else happening as well?

This deserves some more discussion. When you start a leiningen REPL (for example), Leiningen will first look in its local ~/.m2 repository for all of the dependencies in :dependencies. If it can't find any of them there, it will make a request to each of the repositories for that project to see if they have a copy of that dependency. If they do, Leiningen will download it, then recursively download that dependencies dependencies and so-on. Once all of the dependencies are downloaded, Leiningen will add them all to your application's classpath and start the application.

One thing to keep in mind with Leiningen is that there are two JVM's and two classpaths, one for your application, and one for Leiningen. When you add dependencies to :dependencies they go into your application's classpath, when they are added to :plugins, they go to Leiningen's classpath.

Upvotes: 8

Related Questions