Thursday, 11 March 2010

Leiningen or Maven?

Originally posted to the Clojure Google Groups list here:

I'll add my 2 cents worth. I've come from a Java development background to Clojure. A couple of years ago our company migrated from Ant to Maven. At first I really really hated it. I found it difficult to make it do what I wanted it to do. Nowadays, though, it is my build tool of choice.

The turning point was when I realized that the key to using Maven is understanding the Maven model - understanding how Maven wants to build. You don't tell Maven what to do. You just put the files in the places Maven expects, and Maven then _knows_ what to do. My rule of thumb is: if I'm spending a lot of time tweaking configuration and overriding defaults in the pom file then I'm probably doing it wrong.

When I started programming in Clojure I immediately looked for a Maven plugin to build Clojure projects. The first project I worked on I did using the plugin. For my next Clojure project I decided to give Leiningen a spin. Initially I was very impressed. It was easy to get a
project up and running, easy to build, easy to run tests, easy to run a swank server etc. For a couple of weeks I was very happy. But.....

I finally hit a point where Leiningen was no longer working for me. My current project has a Swing GUI, built using Matisse (the Netbeans GUI builder). I couldn't find a way to build the Swing portion and the Clojure portion together using Leiningen. I also couldn't find a way to divide my project up into different sub-modules with one build (maybe I'm guilty of trying to use Leiningen like I use Maven). In any case, I ended up converting the project to use Maven.

Maven has a steep learning curve, but once you get it, it's incredibly powerful.
"The philosophy of Tai Chi Chuan is that if one uses hardness to resist violent force, then both sides are certain to be injured at least to some degree. Such injury, according to tai chi theory, is a natural consequence of meeting brute force with brute force. Instead, students are taught not to directly fight or resist an incoming force, but to meet it in softness and follow its motion while remaining in physical contact until the incoming force of attack exhausts itself or can be safely redirected, meeting yang with yin." (http://
If you fight with Maven, you will lose. If you meet it in softness and follow its motion you will attain build enlightenment...


Finally, I agree with Stuart that polyglot Maven could / should be the way forward. I don't really wrestle with pom files much manually anyway since Netbeans does a very good job of automatically updating them. But Leiningen has given me a taste of writing build files in Clojure, so I will definitely be investigating the polyglot option soon.

To learn more about Maven I would recommend: and

No comments:

Post a Comment