And, since I’m here explaining. lein
was like a self-contained thing, it did make it a bit easier, but it was not as simple or extendable.
You had all the plugins
that would try and monkeypatch things, and it was hard to externally maintain and all that.
Now things are a bit more separated into different area of responsibilities.
- The Clojure CLI (command line interface)
First, you got the command line interface, which is clojure
. Like I said, that’s a shell script, its all the commands you have to do things like start a REPL, launch an application (within the context of an alias), and all that.
- Tools.deps
This manages dependencies and settings for launching Clojure programs with the right set of dependencies and the correct main or init function to call. It’s a Clojure library, you can use it as a library, or you can use it through the Clojure CLI.
This library is configured with the deps.edn
file where you can specify paths and dependencies and all that.
- Tools.build
This manages build tasks, like generate doc, run tests, create an Uberjar, etc.
This is also a Clojure library, and it is always used as a library. So the way its meant to be used is you create a Clojure program, by convention build.clj at the root, and from that program you require tools.build. Then you do whatever you want for your build tasks leveraging tools.build to make it easier.
Finally, the magic trick that this all creates is that everything just becomes simple Clojure programs with utility libraries. And since the Clojure CLI can be used to launch Clojure programs, that’s all you need to create new “commands” on the CLI itself.
It means you don’t have to change the CLI code to add a new CLI “command”. You can just specify an alias, and use -M
, -T
, -T:
, or -X
to call the “command”, which is just a Clojure program exposing either a main method -M
, or a callable function -X
.
And depending if the program needs to be launched within the context of your project or not, you use -T
or -T:
instead of -M
and -X
.
Its a bit less easy at first, but once you get it, it makes a lot more sense, where lein
was more magical and obtuse. The new way builds upon simple things that combine.