Saturday, September 17, 2011

Leiningen and Eclipse

I'm now fairly comfortable with leiningen, though I still feel a frisson of anxiety whenever I run it. I know that Maven is lurking there somewhere, and my experiences with Maven have not been happy.

I'm also a bit leery of letting lein download and install arbitrary software from external sources. I'll need to set up a local repository, which will mean a closer brush with Maven that I've had before.

It's annoying, but seems unavoidable. Clojure libraries and tutorials generally assume that you're using leiningen.

At least the lein/Eclipse combo makes it simple to create and populate an Eclipse Clojure project.

Here's what you do:

  1. In the directory in which  you want to create your project, run lein new
  2. cd to the newly-created directory
  3. open project.clj in your text editor of choice
  4. add :dev-dependencies [[lein-eclipse "1.0.0"]]
  5. save the file
  6. run lein deps
  7. run lein eclipse
  8. import your newly-created project into eclipse
At the end of stage 4, your project.clj file should look like this
(defproject hadoop-spike "1.0.0-SNAPSHOT"
  :description "FIXME: write description"
  :dependencies [[org.clojure/clojure "1.2.1"]]
  :dev-dependencies [[lein-eclipse "1.0.0"]])

No comments: