No description
Find a file
Phil Hagelberg 2d8ceda7cb
Merge pull request #2411 from rymndhng/patch-1
Use `clojars` repo consistently in document
2018-03-26 08:54:56 -07:00
.circleci Deploy typo and doc update. 2017-12-15 09:14:16 -08:00
bin Enforce TLS 1.2 for PowerShell downloader 2018-02-25 23:24:31 +03:00
doc Use clojars repo consistently in document 2018-03-23 14:12:43 -07:00
lein-pprint Release 1.2.0 of lein-pprint. 2017-11-05 13:15:40 -08:00
leiningen-core Improve the message when insecure HTTP repositories are detected. 2018-02-21 14:04:04 -08:00
resources Use GPL-2.0-or-later as secondary license 2018-02-20 21:09:33 +00:00
src/leiningen Correct project.clj key 2018-03-21 14:30:43 -05:00
test Merge pull request #2279 from gonewest818/unattended-signatures 2018-01-30 19:28:37 -08:00
test_projects Add test for deploying to a file repo 2016-11-03 23:42:39 -07:00
.gitattributes Added .gitattributes to avoid autocrlf for bat files 2010-12-31 22:22:56 -08:00
.gitignore Add circleci config.yml. 2017-05-05 16:03:16 -07:00
bash_completion.bash Remove 'swank' and add missing commands to bash completion. 2016-06-03 12:06:39 -07:00
CONTRIBUTING.md Fix gitlab mirror link. 2018-01-10 09:03:04 -08:00
COPYING tocontrol -> to control in LICENSE files 2016-07-23 01:06:19 +03:00
NEWS.md Warn when hooks or implicit middleware is found. 2018-01-22 14:50:28 -08:00
pcmpl-lein.el Clarify that pcmpl-lein.el is not part of Leiningen. 2013-05-17 13:46:44 -07:00
project.clj Bump the nREPL dep to 0.2.13 2017-12-09 12:33:54 +02:00
README.md We shouldn't recommend use of outdated JDKs. 2017-10-18 10:19:57 -07:00
sample.project.clj Fixed comments formatting. 2017-11-06 02:44:27 +03:00
TUTORIAL.md fix broken link 2011-08-11 20:11:18 -05:00
zsh_completion.zsh Check if in a lein project before ns completion 2014-08-18 13:26:53 -05:00

Leiningen

Leiningen logo

"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..."

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

Installation

If your preferred package manager offers a recent version of Leiningen, try that first as long as it has version 2.x.

Leiningen installs itself on the first run of the lein shell script; there is no separate install script. Follow these instructions to install Leiningen manually:

  1. Make sure you have Java installed; version 8 is recommended at this time.
  2. Download the lein script from the stable branch of this project.
  3. Place it on your $PATH. (~/bin is a good choice if it is on your path.)
  4. Set it to be executable. (chmod +x ~/bin/lein)
  5. Run it.

Windows

There is an installer which will handle downloading and placing Leiningen and its dependencies.

The manual method of putting the batch file. on your PATH and running lein self-install should still work for most users. If you have Cygwin you should be able to use the shell script above rather than the batch file.

N.B.: Avoid using a LEIN_JAR environment variable. If you have one instance of Leiningen on your PATH as well as a LEIN_JAR pointing to a different instance, there is a known problem where lein -v and lein upgrade will refer to the first instance, while usage of Leiningen, such as lein new foobar, will refer to the latter.

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

$ lein deploy clojars # publish the project to Clojars as a library

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.

Configuration

The project.clj file in the project root should look like this:

(defproject myproject "0.5.0-SNAPSHOT"
  :description "A project for doing things."
  :license "Eclipse Public License 1.0"
  :url "http://github.com/technomancy/myproject"
  :dependencies [[org.clojure/clojure "1.8.0"]]
  :plugins [[lein-tar "3.2.0"]])

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.

Documentation

Leiningen documentation is organized as a number of guides:

Usage

Development

Plugins

Leiningen supports plugins which may introduce new 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 lein-pprint) then it should be added to the :plugins list in the :user profile in ~/.lein/profiles.clj. See the profiles guide for details on how to add to your :user profile. The plugin guide explains how to write plugins.

License

Source Copyright © 2009-2017 Phil Hagelberg, Alex Osborne, Dan Larkin, and contributors. Distributed under the Eclipse Public License, the same as Clojure uses. See the file COPYING.

Thanks to Stuart Halloway for Lancet and Tim Dysinger for convincing me that good builds are important.

Images Copyright © 2010 Phil Hagelberg. Distributed under the Creative Commons Attribution + ShareAlike License. Full-size version available.