Leiningen
Prerequisites: Projects with deps.edn and the Clojure CLI
Leiningen (lein) is Clojure's original build tool (from 2009) and
still powers a large share of existing projects. It does everything in
one tool: dependencies, REPL, tests, uberjars, and project templates.
project.clj
;; illustrative — project.clj
(defproject inventory "0.1.0-SNAPSHOT"
:description "Inventory service"
:url "https://example.com/inventory"
:dependencies [[org.clojure/clojure "1.12.6"]
[org.clojure/data.json "2.5.2"]
[ring/ring-core "1.15.5"]]
:main ^:skip-aot inventory.core
:target-path "target/%s"
:profiles {:dev {:dependencies [[org.clojure/test.check "1.1.3"]]}
:uberjar {:aot :all
:jvm-opts ["-Dclojure.compiler.direct-linking=true"]}})
project.clj is itself Clojure code: defproject with a name, a
version, and a map of options. :profiles add settings for development
and for building the uberjar.
Everyday commands
lein new app inventory # create a project from the "app" template
lein repl # start an nREPL server and a REPL client
lein run # run the :main namespace's -main
lein test # run clojure.test tests in test/
lein uberjar # build target/uberjar/inventory-0.1.0-SNAPSHOT-standalone.jar
lein deps :tree # show the dependency tree
deps.edn or Leiningen?
| Clojure CLI + deps.edn | Leiningen | |
|---|---|---|
| Maintained by | Clojure core team | Community |
| Philosophy | Small tools you compose | One batteries-included tool |
| Git dependencies | Yes | Via plugins |
| Builds | tools.build (a library, code in build.clj) |
Built in (lein uberjar) |
| Ecosystem | Most new projects | Many existing projects and plugins |
New projects increasingly use the CLI; you'll meet both. Editors (Calva, Cursive, CIDER) support both, and the language and libraries are the same either way.