Search This Blog

Sunday, October 3, 2010

Polyglot Maven with Clojure and Emacs : My Edge is Bleeding

After a couple of hours hacking, I admit defeat. Google is not my friend any more. I am inches from my goal, and yet so far ....

I decided to try out polyglot maven, which promises the joy of maven without the xml of maven.

It's still pre-release, so it can't be criticized for the fact that its instructions don't work, or for the fact that build from source is broken.

However, it is almost possible to figure out what to do:

Download the prebuild 0.8:
$ wget

Unzip it:
$ unzip

Run it, using the pom.clj below as the project file, and ask it to open a swank server:

$ pmaven-0.8-SNAPSHOT/bin/mvn -f pom.clj clojure:swank
Connection opened on local port  4005
#<ServerSocket ServerSocket[addr=localhost/,port=0,localport=4005]>

All is well. This works on my machine, running Ubuntu 10.04 in a guest account.

But I have cheated. Crucial jars live in the clojars repository.
I cannot figure out how to add the clojars repository to my pom.clj.

However, if you run maven on a corresponding pom.xml, with the same version and that repository listed, then it will download the relevant jars and put them in the local repository, which is good enough. After that maven will find them.

Polyglot maven understands the pom.xml file below as well. Just put it in your current directory and run:

$ pmaven-0.8-SNAPSHOT/bin/mvn -f pom.xml clojure:swank

And that will bring the necessary jars into your local repository. After that the pom.clj file is enough.

I am not claiming that this is in any way an improvement yet, but it looks very promising.

If someone can tell me what to add to pom.clj to add clojars, we are done.

I have grown rather fond of maven's pom.xml files. Soon they will be gone. I will actually miss them.

But brevity is the soul of not cocking things up. Here are the two files:


(defproject main "com.aspden:polyglot-maven-test:1.0-SNAPSHOT"
    :dependencies [["org.clojure:clojure:1.3.0-alpha1"]
    :plugins [["com.theoryinpractise:clojure-maven-plugin:1.3.4"]])








  1. P.S. I tried to report the various problems I came across an issue via github, but they've turned off the github issue tracker and want you to use some immense enterprise catastrophe that requires you to fill in an eight-page form in order to tell them something.

    And at the start of the form it's not at all clear if you can ever get to the end of the process. It seems they would rather not hear about people's attempts to use it at this stage, which is fair enough I guess.

  2. It looks like you're (possibly) using my origin clojure DSL there which has been totally rewritten. I'm not sure if I had exposed/implementing the repositories support or not off hand.

    However, in the maven/bin directory there is the transformer, which you can run: transform pom.xml pom.clj to convert your XML pom into a clojure pom, if the repository support is there - you'll see if written out in the new clojure pom.

    The rewritten clojure support in the trunk/master of polyglot is a direct mapping of the entire maven Model, so whilst is a bit more verbose in parts does support the entire model without additional work being done.

    I've not looked at polyglot maven for a good 6 months or so but have been meaning to get up to speed on it again since the release of Maven 3.

    Mark ( - )