Skip to content

Leiningen Guide — Clojure Project Management and Build Tool

DodaTech Updated 2026-06-28 1 min read

In this tutorial, you will learn about Leiningen Guide. We cover key concepts, practical examples, and best practices to help you master this topic.

Leiningen (lein) is the standard build automation and project management tool for Clojure -- handling dependency resolution, REPL startup, testing, packaging, and deployment through a declarative project.clj file.

Installing Leiningen

# Download the lein script
wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein
chmod +x lein
sudo mv lein /usr/local/bin/

# Run to download self-install
lein

# Verify
lein version

Creating a Project

# Create new project
lein new app my-project
cd my-project

# Project structure
# my-project/
#   project.clj
#   src/my_project/core.clj
#   test/my_project/core_test.clj

project.clj

(defproject my-project "0.1.0-SNAPSHOT"
  :description "My Clojure project"
  :dependencies [[org.clojure/clojure "1.11.1"]
                 [ring/ring-core "1.12.0"]
                 [compojure "1.7.0"]]
  :main ^:skip-aot my-project.core
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all}})

Common Commands

lein repl          # Start REPL with project deps
lein run           # Run main function
lein test          # Run tests
lein uberjar       # Create standalone JAR
lein clean         # Clean build artifacts
lein deps          # Download dependencies
lein search NAME   # Search Clojars for deps

Adding Dependencies

;; Find packages at clojars.org
;; Add to project.clj :dependencies:
:dependencies [[org.clojure/clojure "1.11.1"]
               [cheshire "5.12.0"]       ; JSON
               [http-kit "2.7.0"]        ; HTTP
               [org.clojure/core.async "1.6.681"]]

Common Mistakes

1. Version conflicts

Check for dependency conflicts with lein deps :tree.

2. Missing ^:skip-aot for dev

Without it, compilation is slow. Use ^:skip-aot during development.

3. Forgetting lein repl vs lein run

lein repl starts interactive session. lein run executes -main.

FAQ

{{< faq question="What is the difference between Leiningen and deps.edn?" >}} Leiningen uses project.clj (older standard). deps.edn is the newer Clojure CLI tool. Leiningen is still widely used and more full-featured for builds. {{< /faq >}}

{{< faq question="What is Clojars?" >}} Clojars is the community Clojure package Repository, similar to Maven Central or npm. Add dependencies from Clojars in project.clj. {{< /faq >}}

{{< faq question="How do I run a specific namespace's -main?" >}} lein run -m my.namespace runs the -main function in the specified namespace. {{< /faq >}}

What's Next

Now learn about the Clojure REPL.

Topic Description Link
REPL Interactive development {{< ref "03-repl" >}}
Syntax Core syntax and forms {{< ref "04-syntax" >}}

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro