Leiningen and Clojure

(written by lawrence krubner, however indented passages are often quotes). You can contact lawrence at: lawrence@krubner.com, or follow me on Twitter.

Colin Steele writes:

If you’re debugging clojure, here’s an easy way to set jswat’s classpath by launching jswat from lein

and he offers the code to do it. I have not used Leiningen so I started looking for information about it. Zef offers this description:

Everybody who once used Java, struggled with Java’s classpath at some point during their career. You have to put all the right paths in there, the right .jar files and so on, both when compiling and running your Java project. To make this somewhat simpler you typically end up doing it either in an IDE, or using a tool like Ant or Maven. These are pretty heavy weight tools, and the latter too involve writing XML, which hardly anybody does for fun anymore.

Leiningen is a simple build tool for Clojure, based on Maven (I’m pretty sure). It offers a simple, Clojuresque way of constructing build files for your Clojure projects (which run on the JVM).

Anything easier than Maven must be a good thing. My last Java project I built with Netbeans, and most of the build process was automated, but then I tried to mix in some Groovy code, and I got an error. The stack trace said that the build was failing, and trying to figure out why was a royal pain.

I notice that this looks like exhaustive documentation. I like the fixed structure:

Leiningen uses fixed structure of project — in the root directory of the project you need to have the project.clj file, that contains project’s definition. The only necessary component of the definition is defproject — Clojure’s macro, that is expanded into set of build instructions. project.clj can also include other code, written in Clojure, that will executed during build process.

Project’s source code should be stored in src directory, tests — in test directory, and additional resources, used by project — in resources directory. The lib directory is used to store libraries, used by project — they are copied there with the lein deps command. List of libraries is calculated using information about dependencies, declared in project. If you want to use library, that isn’t stored in one of the Maven’s repositories, then you can just copy this library into lib directory, and it will available to your project.

Post external references

  1. 1
    http://colinsteele.org/2010/09/launch-a-clojure-debugging-session-with-jswat-with-lein/
  2. 2
    http://github.com/technomancy/leiningen/blob/master/README.md
  3. 3
    http://zef.me/2470/building-clojure-projects-with-leiningen
  4. 4
    http://alexott.net/en/clojure/ClojureLein.html
Source