Sunday, 10 January 2010

Configuring My Development Environment

I'm going for the following configuration:
  1. Use NetBeans to do all the Java / Maven specific stuff.
  2. Use Emacs to do all the Clojure programming.
  3. Use the clojure-maven-plugin to compile the .clj files, and to start the swank server for the project.
If I understand it correctly, this means that I can add dependencies to my pom file, then start up the swank server using "mvn clojure:swank". That will make all the jar files pulled in by Maven available in the Slime repl in Emacs.

I could do all my development in Emacs, but I am unwilling to part with NetBeans. For the pure Java / Maven side, I am very comfortable with NetBeans. This setup gives me the best of both worlds - NetBeans does what it is good at. Emacs does what it is good at.

Let's test this out. I will create a project, add a Jakarta Commons dependency, then try to call it from the repl. Here is the pom:
<project xmlns:xsi="" xmlns="" xsi:schemalocation="">



Some things to note:
  1. I added a repository to pick up the clojure dependency
  2. I had to manually install the swank-clojure dependency to my local repository.
If I then start up the swank server with "mvn clojure:swank", I am able to connect to it from Emacs using M-x slime-connect. Now, am I able to access the Jakarta Commons Lang classes?
user> (org.apache.commons.lang.StringUtils/isBlank " ")
user> (org.apache.commons.lang.StringUtils/isBlank "not blank ")
Yes! That proves the set up.

And does the clojure-maven-plugin compile my .clj files?
neill@korzybski:~/src/mrtj-clojure$ ls target/classes/com/nwalex/mrtj
test$hello_world__3.class  test__init.class  test$loading__6309__auto____1.class
Yes it does.

I am very happy with this. I started down this road yesterday afternoon when I struggled and failed to configure the NetBeans Enclojure plugin to work with Clojure 1.1.0. 1 day later I have a working Clojure development environment integrating NetBeans, Maven, and Emacs. I don't need to mess about with classpaths. Maven will sort all of that out for me when I add dependencies to the pom.

Time to start hacking!

No comments:

Post a Comment