Clojure Maven2 POM
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is even with GeorgeJahad:master.
carview.php?tsp= Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
carview.php?tsp= .gitignore
carview.php?tsp= README
carview.php?tsp= pom.xml

README

Clojure POM for Maven2
======================
Q: A Maven POM for Clojure ?!?
> Yes. Don't run away with your hair on fire. This is only used for dependency
management (and optionaly AOT compile clojure into java classes).
Q: How do I get started ?
> It's easy. Just follow the steps below and you'll
have access to tens of thousands of Java libraries inside Clojure
* Make sure you have > Java5 on your box
* Install Maven [ https://maven.apache.org ]
* Install Clojure Contrib & POM with git & maven.
  You can find maven-friendly repos on my github account.
NOTE: Clojure 1.0.0 is now on the maven repos officially
git clone git://github.com/dysinger/clojure-pom.git
cd clojure-pom
mvn install
cd ..
git clone git://github.com/dysinger/clojure-contrib.git
cd clojure-contrib
git checkout -b 1.0-SNAPSHOT origin/1.0-SNAPSHOT
mvn install
cd ..
* Now create a new clojure project.  You can create maven archetypes
  if your maven-fu is brown-belt or above.
  Sometimes good ol' 'here' files are easier. I do it like this.
mkdir my-project
cd my-project
cat >pom.xml <<\THEEND
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="https://maven.apache.org/POM/4.0.0"
         xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="https://maven.apache.org/POM/4.0.0
                             https://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.clojure</groupId>
    <artifactId>clojure-pom</artifactId>
    <version>1.0.0</version>
  </parent>
  <groupId>myorg</groupId>
  <artifactId>myproj</artifactId>
  <name>${artifactId}</name>
  <version>1.0-SNAPSHOT</version>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <!-- optional: precompile some clojure -->
          <execution>
            <id>compile</id>
            <configuration>
              <tasks>
                <java fork="true"
                      classname="clojure.lang.Compile"
                      classpathref="maven.compile.classpath">
                  <sysproperty key="clojure.compile.path"
                               value="${project.build.outputDirectory}" />
                  <arg value="myorg.myproj.hello" />
                </java>
              </tasks>
            </configuration>
          </execution>
          <!-- optional: test-is some clojure
          <execution>
            <id>test</id>
            <configuration>
              <tasks>
                <java classname="clojure.main"
                      classpathref="maven.test.classpath">
                  <arg value="-e"/>
                  <arg value="(use 'tests) (run-all-tests)"/>
                </java>
              </tasks>
            </configuration>
          </execution>
          -->
        </executions>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <!-- optional: 3rd party dependencies -->
    <dependency>
      <groupId>org.clojure</groupId>
      <artifactId>clojure-contrib</artifactId>
      <version>1.0-SNAPSHOT</version>
    </dependency>
    <dependency>
      <groupId>commons-math</groupId>
      <artifactId>commons-math</artifactId>
      <version>1.2</version>
    </dependency>
  </dependencies>
</project>
THEEND
mkdir -p src/myorg/myproj
cat >src/myorg/myproj/hello.clj <<\THEEND
(ns myorg.myproj.hello
  (:import [org.apache.commons.math.random JDKRandomGenerator]))
(defn main []
  (println "Hello from org.apache.commons.math.random: "
    (.nextInt (JDKRandomGenerator.))))
THEEND
mvn process-resources ; # <- now your are ready for emacs slime
mvn compile           ; # <- see it compile your clojure code
mvn test              ; # <- see it test your clojure code
mvn install           ; # <- install a jar for dependant projects (default)
mvn assembly:assembly ; # <- build one big jar for easy deploys
Q: How can I use this in Emacs & Slime ?
> Most of us use emacs 23 (trunk) and slime (trunk) with
Philip Hagelberg's emacs-starter-kit.  I won't cover all that here.
It's on github.  https://github.com/technomancy/emacs-starter-kit
Ask about setup particulars on IRC.  It's rapidly evolving.