Managing Profiles, Aliases, and Environments
Real projects need different settings for dev, test, and production. This lesson teaches Leiningen profiles and deps.edn aliases to manage configuration and environment-specific builds.
Managing Profiles, Aliases, and Environments is a free Clojure Functional Programming & JVM Backend Development lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Clojure Functional Programming & JVM Backend Development learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Why Profiles and Aliases
You should not ship dev tooling to production. Profiles (Leiningen) and aliases (deps.edn) let one project produce different configurations on demand.
Leiningen Profiles
A profile in project.clj overlays extra config, such as dev-only dependencies, that merge into the base.
{:profiles
{:dev {:dependencies [[midje "1.10.9"]]}
:uberjar {:aot :all}}}Activating a Profile
Use the with-profile task to run a command under a chosen profile.
lein with-profile +uberjar uberjarDefault Profiles
The :dev profile activates automatically for local commands like lein repl, so test tooling is available without extra flags.
deps.edn Aliases
In tools.deps, an alias adds dependencies or options under a keyword you activate with the -M or -X flags.
{:aliases
{:test {:extra-paths ["test"]
:extra-deps {lambdaisland/kaocha {:mvn/version "1.91.1392"}}}}}Running an Alias
Invoke an alias from the CLI; multiple aliases combine.
clojure -M:test:dev -m kaocha.runnerEnvironment Variables
Read configuration from the environment so the same artifact behaves differently per deployment without recompiling.
(def db-url (System/getenv "DATABASE_URL"))
(println db-url)Config Files Per Environment
Keep an config.edn read at startup. Choose the file via an env var so prod and dev load different settings.
(require '[clojure.edn :as edn])
(def config
(edn/read-string (slurp (or (System/getenv "CONFIG") "dev.edn"))))Keep Secrets Out of Source
Never commit credentials. Inject them through environment variables or a secrets manager, and reference them from profiles or aliases only by name.
Composition Over Duplication
Both profiles and aliases compose. Layer a base plus environment overlays rather than maintaining several near-identical full configs.
Reproducible Builds
Pin versions and avoid implicit defaults so a build on CI matches a build on a laptop. Profiles and aliases make these differences explicit and intentional.
Quick Check
Test your profiles and aliases knowledge.
Recap
You learned Leiningen profiles, deps.edn aliases, activating them from the CLI, reading environment variables and per-environment config files, keeping secrets out of source, and composing layers for reproducible builds.
Frequently asked questions
Is the “Managing Profiles, Aliases, and Environments” lesson free?
Yes — the full text of “Managing Profiles, Aliases, and Environments” is free to read here on the web, and the Clojure Functional Programming & JVM Backend Development course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Clojure Functional Programming & JVM Backend Development course, upgrade to CoddyKit PRO.
What will I learn in “Managing Profiles, Aliases, and Environments”?
Real projects need different settings for dev, test, and production. This lesson teaches Leiningen profiles and deps.edn aliases to manage configuration and environment-specific builds. You practise Clojure Functional Programming & JVM Backend Development with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Clojure Functional Programming & JVM Backend Development?
No prior experience is required. Clojure Functional Programming & JVM Backend Development on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Managing Profiles, Aliases, and Environments” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Clojure Functional Programming & JVM Backend Development lesson?
Yes. Every Clojure Functional Programming & JVM Backend Development lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Leiningen and Deps.edn Basics
- Managing Dependencies & Plugins
- Building, Testing & Deployment
- Managing Profiles, Aliases, and Environments