How to install a leiningen plugin?

kes picture kes · Mar 6, 2010 · Viewed 7.3k times · Source

How do I install a leiningen plugin?

For example, leiningen-run?

I see this thing called "clojars.org", and how to "push" to it, but I don't see anything about "pulling" from it.

Answer

strangemonad picture strangemonad · May 18, 2013

Depending on a plugin

With Leiningen 2.0 and greater you specify which plugins you want as values to :plugins in your project map. See the sample project.clj file. Note that "sample" is a bit of a misnomer, it's a reference for all possible (built-in) keys and documentation of their defaults.

lein-run

The lein-run functionality is now part of core leiningen and doesn't need to be specified as a plugin

clojars.org

Clojars is a repository of clojure libraries quite similar to maven central (or to some lesser extent, rubygems). You don't pull from it explicitly. Instead, Leiningen is configured to search through a standard set of repos for your :dependencies E.g. maven central and clojars. Maven uniquely identifies its dependencies (artifacts in maven parlance) by a triple (group-name, artifact-name, version). Leiningen leverages the exact same mechanism with the exception that the group name does not have the restriction of being a reverse URI the way it must be with maven central. In practice you'll tend to see many libraries published in clojars where the name nicely matches the clojure namespace and github project name without the annoying com.mydomain.awesomelib

You can set your own repos to be searched (or tweak various options) via :repositories in you project.clj. You can similarly set :mirrors if you have an in-house mirror of a maven repo.

"Installing" an unpublished plugin

Finally, though I don't think that's directly what you were asking but it's still interesting, If you're developing a plugin or what to depend on a plugin that hasn't been officially published, you can set :plugin-repositories