Clojure Aliases and deps.edn Workflows — :dev, :test, :run, and Stacking | Episode 24
0views
C
CelesteAI
Description
One `deps.edn`, many workflows. In this episode we wire up four aliases — `:run`, `:dev`, `:test`, and `:json` — and drive the same project four different ways from the command line: run it, test it, REPL against it, or spin up a REPL with an extra library. Then we stack aliases — `clj -A:dev:json` — and get both classpaths in one session.
We also untangle the one confusing pair in the Clojure CLI: **`-M` applies `:main-opts` and runs**; **`-A` applies classpath modifications only** (perfect for REPLs). Pick the wrong one and you either auto-run a main function you didn't want, or you start a REPL with no main available.
Student code: https://github.com/GoCelesteAI/clojure-for-beginners/tree/main/episode24
Every keystroke is shown on screen with generous pauses so you can follow along at your own pace.
What You'll Learn:
- `:aliases` in `deps.edn` — each alias is a classpath/runtime slice
- `:extra-paths` — add `test/`, `dev/`, etc. to the classpath under this alias
- `:extra-deps` — pull in a library for just this alias (no pollution of the main `:deps`)
- `:main-opts` — what `-M:alias` runs
- `-M` vs `-A` — run vs REPL
- Alias stacking — `clj -A:dev:json` merges classpaths across aliases
- A realistic four-alias pattern: `:run` / `:dev` / `:test` / a feature-scoped alias (`:json`)
Timestamps:
0:00 - Intro
0:15 - Preview: modular modifiers that stack
0:55 - The full deps.edn with four aliases
1:19 - clj -M:run — the runner
1:28 - clj -M:run with an argument
1:45 - clj -M:test — the test runner alias
2:05 - clj -A:dev — REPL with test path
2:21 - Run tests from the REPL
2:39 - Control-D
2:51 - clj -A:json — REPL with cheshire
3:09 - parse-string works
3:21 - Control-D
3:33 - clj -A:dev:json — aliases stack
3:57 - Parse JSON in the stacked REPL
4:09 - Run tests in the stacked REPL
4:23 - Control-D
4:37 - Recap
5:16 - What's next: Episode 25
Key Takeaways:
1. Aliases live under `:aliases` in `deps.edn`. Each one is a small map of classpath/runtime tweaks (`:extra-paths`, `:extra-deps`, `:main-opts`).
2. `-M:alias` applies that alias's modifications **and** runs `:main-opts` as a main. Use for CLI entry points (runners, test runners, build scripts).
3. `-A:alias` applies classpath modifications **only** and starts a REPL. Use for interactive sessions where you want tools available but no auto-run.
4. Colon-separated aliases stack: `clj -A:dev:json`. Classpaths merge across them — the REPL gets the union of all enabled aliases' paths and deps.
5. Keep the main `:deps {}` minimal. Put tool-specific libraries under scoped aliases so production runs stay lean.
Phase 4 wraps here — namespaces, projects, and testing, all of it. Phase 5 starts next: state and concurrency.
Taught by CelesteAI. Like and subscribe for more Clojure tutorials!