README.md

Leiningen

"Leiningen!" he shouted. "You're insane! They're not creatures you can
fight—they're an elemental—an 'act of God!' Ten miles long, two
miles wide—ants, nothing but ants! And every single one of them a
fiend from hell..."

from Leiningen Versus the Ants by Carl Stephenson

Leiningen is for automating Clojure projects without setting your hair on fire.

Installation

If your preferred
package manager
has a relatively recent version of Leiningen, try that first.
Otherwise you can install by hand:

Leiningen bootstraps itself using the lein shell script;
there is no separate install script. It installs its dependencies
upon the first run on unix, so the first run will take longer.

The link above will get you the 2.x preview release. There is still a
lot of extant material on the Web concerning the older
Leiningen 1.x
version, which is still available if you need to work on older
projects that aren't compatible with 2.x yet. The
upgrade guide
has instructions on migrating to version 2.

On Windows most users can get
the batch file.
If you have wget.exe or curl.exe already installed and in PATH, you
can just run lein self-install, otherwise get the standalone jar from the
downloads page.
If you have Cygwin you should be able to use
the shell script above rather than the batch file.

Basic Usage

The
tutorial
has a detailed walk-through of the steps involved in creating a new
project, but here are the commonly-used tasks:

$ lein new [TEMPLATE] NAME # generate a new project skeleton
$ lein test [TESTS] # run the tests in the TESTS namespaces, or all tests
$ lein repl # launch an interactive REPL session
$ lein run -m my.namespace # run the -main function of a namespace
$ lein uberjar # package the project and dependencies as standalone jar

Use lein help to see a complete list. lein help $TASK shows the
usage for a specific task.

You can also chain tasks together in a single command by using the
do task with comma-separated tasks:

$ lein do clean, test foo.test-core, jar

Most tasks need to be run from somewhere inside a project directory to
work, but some (new, help, search, version, and repl) may
run from anywhere.

The lein new task generates a project skeleton with an appropriate
starting point from which you can work. See the
sample.project.clj
file (also available via lein help sample) for a detailed listing of
configuration options.

The project.clj file can be customized further with the use of
profiles.

Plugins

Leiningen supports plugins which may contain both new tasks and hooks
that modify behaivour of existing tasks. See
the plugins wiki page
for a full list. If a plugin is needed for successful test or build
runs, (such as lein-tar) then it should be added to :plugins in
project.clj, but if it's for your own convenience (such as
swank-clojure) then it should be added to the :plugins list in the
:user profile from ~/.lein/profiles.clj. The
plugin guide
explains how to write plugins.

Patches are preferred as GitHub pull requests, though patches from
git format-patch are also welcome on the mailing list. Please use
topic branches when sending pull requests rather than committing
directly to master in order to minimize unnecessary merge commit
clutter.

Contributors who have had a single patch accepted may request commit
rights on the mailing list or in IRC. Please use your judgment
regarding potentially-destabilizing work and branches. Other
contributors will usually be glad to review topic branches before
merging if you ask on IRC or the mailing list.

Contributors are also welcome to request a free
Leiningen sticker by asking on the
mailing list and mailing a self-addressed, stamped envelope.

Building

You don't need to "build" Leiningen per se, but when you're using a
checkout you will need to get its dependencies in place.

For the master branch, use Leiningen 1.x to run lein install in the
leiningen-core subproject directory. When the dependencies change
you will also have to do rm .lein-classpath in the project root.

Once you've done that, symlink bin/lein to somewhere on your
$PATH, usually as lein2 in order to keep it distinct from your
existing installation.