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 http://polyglot.sonatype.org/site-nexus/download/pmaven-0.8-SNAPSHOT-bin.zip


Unzip it:
$ unzip pmaven-0.8-SNAPSHOT-bin.zip

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/127.0.0.1,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:



pom.clj


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


pom.xml


<project>

  <modelVersion>4.0.0</modelVersion>
  <groupId>com.aspden</groupId>
  <artifactId>polyglot-maven-test</artifactId>
  <version>1.0-SNAPSHOT</version>
  <name>polyglot-maven-test</name>
  <description>polyglot-maven-test</description>


  <repositories>
    <repository>
      <id>central</id>
      <url>http://repo1.maven.org/maven2</url>
    </repository>
    <repository>
      <id>clojure</id>
      <url>http://build.clojure.org/releases</url>
    </repository>
    <repository>
      <id>clojars</id>
      <url>http://clojars.org/repo/</url>
    </repository>
  </repositories>

  <dependencies>
    <dependency>
      <groupId>org.clojure</groupId>
      <artifactId>clojure</artifactId>
      <version>1.3.0-alpha1</version>
    </dependency>
    <dependency>
      <groupId>org.clojure</groupId>
      <artifactId>clojure-contrib</artifactId>
      <version>1.2.0-SNAPSHOT</version>
    </dependency>
    <dependency>
      <groupId>jline</groupId>
      <artifactId>jline</artifactId>
      <version>0.9.94</version>
    </dependency>
    <dependency>
      <groupId>swank-clojure</groupId>
      <artifactId>swank-clojure</artifactId>
      <version>1.3.0-SNAPSHOT</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>com.theoryinpractise</groupId>
        <artifactId>clojure-maven-plugin</artifactId>
        <version>1.3.4</version>
      </plugin>
    </plugins>
  </build>
  
</project>

2 comments:

  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.

    ReplyDelete
  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 ( mark@talios.com - twitter.com/talios )

    ReplyDelete

Followers