A Clojure project managed by Leiningen uses a simple clojure file called
project.clj which allows developers to define a whole range of stuff about their projects. To get started you only have to define a name, a version of Clojure and any dependencies in your
project.clj and Leininge does the rest.
So lets take a quick look under the hood of Leiningen and its defproject macro to see what is going on.
The defproject macro when run creates a simple map of your project to work with. Here is an example map for my project, generated by the command
lein pprint project.clj
If you add something to your
project.clj file and wonder what is has changed underneath, then looking at the project map is very useful.
Using the project map to understand what dependencies you have pulled in could be a great way to streamline your project, or help debug it if something when wrong after adding a new dependency.
Leiningen also merges your profile configuration
~/.lein/profiles.clj along with your
project.clj settings when creating the project map. This can be seen in the above example. Near the end of the file is a
:plugins keyword, the following 3 lines are plugins I defined in my profile. Leiningen will work out the smartest way to merge your
project.clj. If in doubt, you can check the project map.
Here is the source code for the
You can also see the source code of the defproject macro in context of the Leingingen project at its Github repository.
This work is licensed under a Creative Commons Attribution 4.0 ShareAlike License, including custom images & stylesheets. Permissions beyond the scope of this license may be available at @jr0cket