Dr. Julian Timpner

Clojure: Importing a Leiningen Project into Eclipse

To import a Leiningen project into Eclipse, so that you can use CounterClockwise with all its nice features, such as syntax highlighting, there is a handy plugin called lein-eclipse.

To get started, all you have to do is to add this plugin as a dev-dependency in your project’s project.clj.

(defproject my-project "1.0.0-SNAPSHOT"
  :description "My Clojure Leiningen Project"
  :dependencies [
        [org.clojure/clojure "1.2.0"]
        [org.clojure/clojure-contrib "1.2.0"]
	[ring/ring-jetty-adapter "0.2.5"]
  ]
  :dev-dependencies [
        [lein-eclipse "1.0.0"]
  ]
)

Then, you need to download the project dependencies via

prompt> lein deps

This will automatically install lein-eclipse and add a new task called eclipse to leiningen. Invoking

prompt> lein eclipse

runs this task and creates the Eclipse projects files .project and .classpath. Now you can simply import the project into Eclipse via “File->Import->Existing Project into Workspace”.

Tagged on: