Clojure Templates Are Easy With Leiningen

Using templates to create your Clojure projects can save you a lot of setup time and ensure your team is using the same base configuration and dependencies. There are templates on Clojars.org, however I’ll show you how easy it is to create your own with Leiningen.

I’ll create a simple template based on the leiningen default template, adding a section in the project.clj to give a custom propmt when run in the repl.

Templates used to be a Leinigen pluging called lein-newnew and its repo was the only doucmentation I found and was a little outdated. The plugin is now part of Leiningen and there are a few built in templates. There is also information via lein help new.

If you want to create a template in a more automatic way from a more complete project you created, take a look at the lein-create-template Leinignen plugin.

Read More

Leiningen - Quick Peek Underneath the Defproject Clojure Macro

Leiningen is a project automation tool (think build tool and them some) that uses a Clojure macro to make it easy for Clojure developers to manage their project lifecycle.

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.

Read More