2017-08-27: I’ve published an updated version here.
Leiningen, a Clojure build tool, has the concept of profiles. One thing profiles are useful for is allowing you to have development tools available to a project without having them as dependencies when you release your project. An example of when you might want to do this is when you are using a testing library like expectations.
Some development tools, such as
lein-test-refresh, are
useful to have across most of your Clojure projects. Rather nicely,
Leiningen supports adding global profiles to ~/.lein/profiles.clj
.
These profiles are available in all your projects.
Below is most of my profiles.clj
. I’ve removed some sensitive
settings and what is left are the development tools that I find
useful.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
:plugin-repositories [["private-plugins" {:url "private repo url"}]]
sets a private plugin repository. This allows me to use
Outpace’s private Leiningen templates for
setting up new projects for work.
The next few lines are all related. They setup
humane-test-output.
humane-test-output
makes clojure.test
output more readable. It
makes using clojure.test
much more enjoyable. I highly recommend it.
Sample output can be found in my
Comparing Clojure Testing Libraries
post.
1 2 3 |
|
Next we get to my :plugins
section. This is the bulk of
my profiles.clj
.
1 2 3 4 5 6 7 8 |
|
The first entry is for cider/cider-nrepl
. I write Clojure using
Emacs and CIDER and much of
CIDER’s functionality exists in nrepl middleware found in
cider/cider-nrepl
. This dependency is required for me to be
effective while writing Clojure.
refactor-nrepl
is next.
clj-refactor.el
requires it for some refactorings. I actually don’t use any of those
refactorings (I only use move to let, extract to let, and
introduce let refactorings) but I still keep it around.
com.jakemccrary/lein-test-refresh
is next. This lets me use
lein-test-refresh
globally. lein-test-refresh
runs your clojure.test
tests whenever
a file changes in your project. This is another key development tool
in my process.
Up next is lein-autoexpect
. It was the first Leiningen plugin I
wrote and it enables continuous testing with
expectations.
Both lein-autoexpect
and lein-test-refresh
are projects I created
and maintain. Writing lein-autoexpect
was my first
exposure to continuous testing and it changed how I develop code. I
find it frustrating to develop without such a tool.
Next up is lein-ancient. It checks your project.clj for outdated dependencies and plugins. It isn’t something that gets used every day but it is super useful when you need it.
The next two entries are for jonase/eastwood and lein-kibit. They are both tools that look at your Clojure code and report common mistakes. I don’t use either consistently but I do find them useful. I’ve found bugs with eastwood.
The final plugin is lein-pprint
.
lein-pprint
prints out your project map. It is useful for trying to grasp what is
going on when messing around with various Leiningen options.
The final part, seen below, of my profiles.clj
is configuration for
lein-test-refresh.
It configures lein-test-refresh
to use
terminal-notifier to
notify me when my tests pass or fail. Using a continuous tester that
allows flexible notification is useful. Not having to glance at a
terminal to see if your tests are passing or failing is great.
1
|
|
That is my ~/.lein/profiles.clj
. I don’t think it contains anything
mind blowing but it definitely contains a useful collection of Clojure
development tools. I encourage you to check out them out and to think
about what tools you should be putting into your global :user
profile.