Skills2026年5月19日·1 分钟阅读

Leiningen — Automate Clojure Projects Without Losing Your Mind

Leiningen is the de facto build tool for Clojure. It handles dependency management, project scaffolding, REPL launching, testing, and packaging with a single command-line interface.

Agent 就绪

先审查再安装

这个资产需要先审查。复制的指令会要求 Agent dry-run、列出写入项,确认后再继续。

Needs Confirmation · 64/100策略:需确认
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Leiningen Clojure Build Tool
先审查命令
npx -y tokrepo@latest install de62b9aa-5339-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run,确认写入项后再运行此命令。

Introduction

Leiningen is the most widely used build tool in the Clojure ecosystem. It handles the entire project lifecycle—from scaffolding a new project to managing dependencies, running tests, starting a REPL, and building deployable artifacts—all driven by a declarative project.clj file.

What Leiningen Does

  • Resolves and downloads dependencies from Maven Central and Clojars repositories
  • Scaffolds new projects from templates via lein new <template> <name>
  • Launches a Clojure REPL with the project classpath fully configured
  • Runs tests with lein test and generates reports
  • Builds uberjars (standalone JARs with all dependencies bundled) for deployment

Architecture Overview

Leiningen is a Clojure application distributed as a shell script bootstrap. The bootstrap downloads the Leiningen core JAR on first run and delegates to it. Projects are configured through project.clj, a Clojure data structure. Dependency resolution uses Apache Maven's Aether library under the hood. Leiningen's plugin architecture allows the community to extend it with tasks for code formatting, Docker builds, ClojureScript compilation, and more.

Self-Hosting & Configuration

  • Install by downloading the lein script and placing it on your PATH
  • All project settings live in project.clj at the project root
  • User-level settings go in ~/.lein/profiles.clj for global plugins and JVM options
  • Repositories are configurable: add private Maven repos or S3-backed repositories
  • JVM options are set via :jvm-opts in project.clj or via LEIN_JVM_OPTS environment variable

Key Features

  • Template-based project creation with community templates for web apps, libraries, and more
  • nREPL integration for connecting editors like Emacs (CIDER), IntelliJ (Cursive), and VS Code (Calva)
  • Profile system for environment-specific configuration (dev, test, production)
  • Plugin ecosystem covering tasks like lein-ring for web servers and lein-cljsbuild for ClojureScript
  • Offline mode and local repository caching for reproducible builds without network access

Comparison with Similar Tools

  • Clojure CLI (deps.edn) — official tool focused on dependency management; Leiningen provides a broader task runner and plugin system
  • Boot — alternative Clojure build tool using a pipeline model; less widely adopted than Leiningen
  • Maven — Java build tool; Leiningen wraps Maven's resolver but uses a simpler Clojure-native configuration
  • Gradle — powerful but complex; Leiningen is purpose-built for Clojure with less configuration overhead

FAQ

Q: Should I use Leiningen or the official Clojure CLI? A: Leiningen is better for projects that need a full build lifecycle with plugins. The Clojure CLI is lighter and preferred for library development and simple dependency management.

Q: Can Leiningen build ClojureScript projects? A: Yes. Use the lein-cljsbuild plugin or lein-shadow (wrapping shadow-cljs) for ClojureScript compilation.

Q: Does Leiningen work with Java dependencies? A: Yes. Leiningen resolves dependencies from Maven Central and any Maven-compatible repository, so all Java libraries are accessible.

Q: How do I create a standalone executable? A: Run lein uberjar to produce a self-contained JAR file that includes all dependencies and can be run with java -jar.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产