ngocdaothanh napisaĆ(a):
> I'm new to Maven. Thank you for the explanation.
>
> Using git-submodules and <sourceDirectories> is a good idea. Prior to
> using your plugin, I use clojure and clojure-contrib with Maven like
> this:
>
> 1. Manually download from GitHub and compile clojure and clojure-
> contrib.
> 2. Install them to the local Maven repository:
> mvn install:install-file -DgroupId=org.clojure -DartifactId=clojure -
> Dversion=SNAPSHOT -Dpackaging=jar -Dfile=clojure.jar
> mvn install:install-file -DgroupId=org.clojure -DartifactId=clojure-
> contrib -Dversion=SNAPSHOT -Dpackaging=jar -Dfile=clojure-contrib.jar
> 3. Add clojure and clojure-contrib and other dependencies that my
> project uses in pom.xml:
> ...
> <dependencies>
> <dependency>
> <groupId>org.clojure</groupId>
> <artifactId>clojure</artifactId>
> <version>SNAPSHOT</version>
> </dependency>
> <dependency>
> <groupId>org.clojure</groupId>
> <artifactId>clojure-contrib</artifactId>
> <version>SNAPSHOT</version>
> </dependency>
> ...
> </dependencies>
> ...
>
> 4. Use Exec Maven Plugin (http://mojo.codehaus.org/exec-maven-plugin/)
> to run my Clojure file:
> mvn exec:java -Dexec.mainClass="clojure.main" -Dexec.args="path/to/my/
> clojure/file.clj"
>
> I want to ask is there a better way to use clojure and clojure-contrib
> and running Clojure file with Maven?
Actually I managed to make a little bit more useful pom-template.xml
(from clojure git repository) and now I'm able to install clojure
in local maven repository just using this commands:
$ git pull
$ ant init-version
$ mvn install
I'm going to change pom.xml in clojure-contrib in the same way.
Needed XMLs look as follows:
# clojure-jar.xml - assembly descriptor
<assembly>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${build}</directory>
<outputDirectory></outputDirectory>
<includes>
<include>**/*.class</include>
</includes>
</fileSet>
<fileSet>
<directory>${cljsrc}</directory>
<outputDirectory></outputDirectory>
<includes>
<include>**/*.clj</include>
<include>clojure/version.properties</include>
</includes>
</fileSet>
</fileSets>
</assembly>
# slim-jar.xml - assembly descriptor
<assembly>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${build}</directory>
<outputDirectory></outputDirectory>
<includes>
<include>clojure/asm/**</include>
<include>clojure/lang/**</include>
<include>clojure/main.class</include>
</includes>
</fileSet>
<fileSet>
<directory>${cljsrc}</directory>
<outputDirectory></outputDirectory>
<includes>
<include>**/*.clj</include>
<include>clojure/version.properties</include>
</includes>
</fileSet>
</fileSets>
</assembly>
# pom-template.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.clojure</groupId>
<artifactId>clojure-lang</artifactId>
<name>clojure-lang</name>
<version>@clojure-version@</version>
<url>http://clojure.org/</url>
<packaging>pom</packaging>
<description>Clojure core environment and runtime library.</
description>
<licenses>
<license>
<name>Eclipse Public License 1.0</name>
<url>http://opensource.org/licenses/eclipse-1.0.php</url>
<distribution>repo</distribution>
</license>
</licenses>
<properties>
<src>src</src>
<test>test</test>
<jsrc>${src}/jvm</jsrc>
<cljsrc>${src}/clj</cljsrc>
<build>classes</build>
<clojure_jar>clojure-${project.version}</clojure_jar>
<slim_jar>clojure-slim-${project.version}</slim_jar>
</properties>
<repositories>
<repository>
<id>tapestry-snapshots</id>
<url>http://tapestry.formos.com/maven-snapshot-repository/</
url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>releases</id>
<name>release</name>
<url>http://localhost:8081/nexus/content/repositories/releases/
</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>snapshot</name>
<url>http://localhost:8081/nexus/content/repositories/
snapshots/</url>
</snapshotRepository>
</distributionManagement>
<build>
<sourceDirectory>${jsrc}</sourceDirectory>
<outputDirectory>${build}</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<debug>true</debug>
<source>1.5</source>
<target>1.5</target>
</configuration>
<executions>
<execution>
<id>compile-java</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>compile-clojure</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<java classname="clojure.lang.Compile"
classpath="${build}:${cljsrc}"
failonerror="true"
fork="true">
<sysproperty key="clojure.compile.path" value="$
{build}"/>
<arg value="clojure.core"/>
<arg value="clojure.main"/>
<arg value="clojure.set"/>
<arg value="clojure.xml"/>
<arg value="clojure.zip"/>
<arg value="clojure.inspector"/>
<arg value="clojure.walk"/>
<arg value="clojure.stacktrace"/>
<arg value="clojure.template"/>
<arg value="clojure.test"/>
<arg value="clojure.test.tap"/>
</java>
</tasks>
</configuration>
</execution>
<execution>
<id>test-clojure</id>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>!!! For testing use integration-test phase !!!
</echo>
</tasks>
</configuration>
</execution>
<execution>
<id>integration-test-clojure</id>
<phase>integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<java classname="clojure.main" failonerror="true">
<classpath>
<path location="${test}"/>
<path location="${clojure_jar}.jar"/>
</classpath>
<arg value="-e"/>
<arg value="(require '(clojure [test-clojure :as
main])) (main/run-ant)"/>
</java>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>clojure-jar</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>${clojure_jar}</finalName>
<outputDirectory>.</outputDirectory>
<archive>
<manifest>
<mainClass>clojure.main</mainClass>
<addClasspath>true</addClasspath>
</manifest>
<manifestEntries>
<Class-Path>.</Class-Path>
</manifestEntries>
</archive>
<descriptors>
<descriptor>clojure-jar.xml</descriptor>
</descriptors>
</configuration>
</execution>
<execution>
<id>slim-jar</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>${slim_jar}</finalName>
<outputDirectory>.</outputDirectory>
<archive>
<manifest>
<mainClass>clojure.main</mainClass>
<addClasspath>true</addClasspath>
</manifest>
<manifestEntries>
<Class-Path>.</Class-Path>
</manifestEntries>
</archive>
<descriptors>
<descriptor>slim-jar.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<executions>
<execution>
<id>clean-clojure</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<filesets>
<fileset>
<directory>.</directory>
<includes>
<include>${clojure_jar}.jar</include>
<include>${slim_jar}.jar</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
HTH,
Rob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---