Thursday, March 17, 2016

Making Leiningen faster using aliases

Leiningen is a great tool which I use daily when working with Clojure. Therefore I want it to be as fast as possible.

Over the time, several plugins and dependencies did end up in my ~/.lein/profiles.clj file. But the thing is, that each plugin or dependency slows down every lein invocation (e.g. lein new,lein repl, …). It doesn't matter whether the plugin is actually used or not.

For example I'm using ancient plugin which will find outdated dependencies in a project. Common practice is to put such plugin into :plugins vector of the :user profile in ~/.lein/profiles.clj.
{:user {:plugins [[lein-ancient "0.6.8"]]}}

But I don't use this plugin too often. So I not happy paying 250ms startup penalty whenever I run Leiningen. Fortunately it's possible to fix that using aliases (and also profiles if you like). So now I'm using:
{:user {:aliases {"ancient" ["update-in" ":plugins"
                             "conj" "[lein-ancient \"0.6.8\"]"
                             "--" "ancient"]}}}

This way the ancient plugin will be included in :plugins only when I really use it. Leiningen is now fast(er) again!

No comments:

Post a Comment