Using clojure and leiningen with IDEs

11,179

Solution 1

I have had some luck with La Clojure and the "Leiningen" plugin for IntelliJ IDEA. After creating a new project on the command line with lein new, I created a new project in IntelliJ. The Run Configuration Script Path needs to be pointed to the core.clj file, and the Module Settings "Dependencies" need to include the lib directory as a "Module Library."

The Leiningen plugin offers the usual lein commands, so you can build your jar directly from the IDE (or from the shell). You can edit your project.clj file from IDEA, and the Run and Debug seem to work as well.

BTW, I also found this screencast very helpful for getting started with La Clojure.

Solution 2

I've been using Eclipse and CounterClockwise plugin with Leiningen configured to be accessed via External Tools. As the blog post title says, it's a "Poor Man's Integration", but has worked for the example I've tried.

Solution 3

For debugging, syntax highlighting, and running clojure in Eclipse try:

  1. Download counterclockwise for syntax highlighting via external tools using the update site.

  2. Add [lein-eclipse "1.0.0"] to your dependencies in your project.clj file.

  3. Add the plugin manually with command: lein plugin install lein-eclipse "1.0.0". This step is included because just adding the dependency doesn’t always work.

  4. Run the command lein eclipse in project folder to generate eclipse .project and .classpath files. This step might take awhile. If it gets stuck, run it again. It should say "created .project and .classpath".

  5. Restart Eclipse.

  6. Go to |File -> Import -> General -> Existing Projects in Workspace| and select the project folder. You should be able to select the clojure project, debug and run it.

Notes: It doesn't seem to add the dev-dependencies to the project classpath. Also, you need to change your workspace to the folder with the project so it does not make a second copy of the project and uses the actual files.

Solution 4

It's hard to be definitive about this without going through the latest version of every IDE plugin for Clojure, but as someone who keeps up with both Leiningen and the general IDE related developments I have not seen this functionality anywhere. The words IDE, eclipse and netbeans have not been mentioned on the Leiningen google group either, and I would assume that if someone was working on this they would mention it there.

Leiningen is really easy to use on the command-line though, so don't be afraid to give it a try. I've been converting my projects to lein from using both ant and maven previously. The dependency tracking is really handy, and more plugins adding useful new commands are coming out every week. If you really need IDE integration one lightweight way to do it might be to add some kind of custom command command or button that just runs lein in the background.

Solution 5

The best integration I've found is with slime-clojure via lein-swank.

Basically, you use the lein swank command to start a swank server with a Leiningen-configured classpath. Then, you connect to that swank server using M-x slime-connect, and you've got the repl good to go. Well, so long as you can deal with emacs ;)

Share:
11,179
Arthur Ulfeldt
Author by

Arthur Ulfeldt

TLDR Clojure, Docker, Linux, Security, Teaching. https://www.linkedin.com/learning/instructors/arthur-ulfeldt?u=2125562 contacting me: If you are interested in learning clojure you can call me at 1-219-CLOJURE For general Clojure chatting you can find me in IRC #clojure on freenode (thearthur) email < my first name >@< my last name >.com Interests I'm a Clojure and Linux nut with a long standing interest in virtual machines and fancy networking of all sorts. At work I write Clojure Web apps and such full time for yummly.com as well as writing "cloud" deployment systems (some would call it "devops", though I think that term is worn out by now). At home I play with Clojure, Linux, docker, Amateur Radio, and Cryptography quite a bit. I have been a functional programming enthusiast for many years and get quite a lot of personal satisfaction every time i use anything map-reduce related. I am interested in network security related projects and people that are trying to steer the world away from "the corporate castle" metaphor. If you have or are thinking about such a project I would love to hear from you. note for recruiters: I would like to politely decline any positions you might have with "devops" or "language-name engineer" in the title. PS: KE6DRD

Updated on June 06, 2022

Comments

  • Arthur Ulfeldt
    Arthur Ulfeldt almost 2 years

    I'm looking at switching my projects build from Ant to leiningen and wanted to know if there is a Clojure IDE (intellij, eclipse, netbeans) for which the "build" and "debug" buttons will still work?