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 ab
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.
The lein-run functionality is now part of core leiningen and doesn't need to be specified as a plugin
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.
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
If a plugin's available at Clojars, like lein run is, just add it to your project's :dev-dependencies
in project.clj, then say lein deps
in your project's directory to have Leiningen pull in all dependencies. An annotated excerpt from lein run's docs:
(defproject island-wari "0.1"
:description "Web application for playing the Island Wari game."
:main wari
:dependencies [[org.clojure/clojure "1.1.0-master-SNAPSHOT"]
[org.clojure/clojure-contrib "1.1.0-master-SNAPSHOT"]
[org.clojars.liebke/compojure "0.3.1-master"]]
:dev-dependencies [[org.clojure/swank-clojure "1.0"]
[leiningen-run "0.2"]]) ; <--- this bit makes it possible
; to use lein run
Having done the above, you should be able to say lein run
in your project's directory to run your app.
Update: Should you want to write your own plugins for Leiningen, check out this tutorial on nakkaya.com. Even if you're not planning on writing lein plugins, still check out that blog, it absolutely positively rocks.