what is the correct way to "mvn install" clojure-contrib

191 views
Skip to first unread message

B Smith-Mannschott

unread,
Dec 13, 2009, 4:17:24 PM12/13/09
to clo...@googlegroups.com
I'm building clojure-contrib locally from source, and would like to
use the resulting jar file in other projects, which I'm building with
leiningen. To accomplish this, I need to get the clojure-contrib.jar
resulting form the build installed in the correct place in
~/.m2/repository. I've been doing it by hand, because I can't figure
out how to make the combination of build.xml, pom.xml and bubble-gum
that's clojure-contrib's build system do what I need:

(1) ant ci-build
Builds a two "slim" versions of clojure-contrib.jar, one of which is
called "slim", the other isn't. Installs these in the correct
location. i.e. almost works.

The ci-build target claims to "Build clojure-contrib using Clojure
obtained via Maven.", but that doesn't appear to be accurate. Since it
reports

check_hasclojure:
[echo] WARNING: You have not defined a path to clojure.jar so I
can't compile files.
[echo] This will cause some parts of clojure.contrib not to
work (e.g., pretty print).
[echo] To enable compiling, run "ant -Dclojure.jar=<...path
to clojure.jar..>"

Well, it just so happens that I have a recent build of
clojure-1.1.0-master-SNAPSHOT under the name clojure.jar...

(2) ant -Dclojure.jar=clojure.jar ci-build
This does ahead-of-time compilation for all clojure sources. It
produces a "slim" and a non-slim version of clojure-contrib.jar. Only
the "slim" version is actually slim.

This does not, however, appear to ever call "mvn install". So, I'm
left with two correct .jar files, neither of which are visible to
later builds of other projects.

Well gosh-darnit, I've got a pom.xml file lying here. Shouldn't a "mvn
install" just work?

(3) mvn install

[INFO] [jar:jar {execution: default-jar}]
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] [install:install {execution: default-install}]
[INFO] Installing
/home/smithma/w/clojure-contrib/target/clojure-contrib-1.0-SNAPSHOT.jar
to /home/smithma/.m2/repository/org/clojure/clojure-contrib/1.0-SNAPSHOT/clojure-contrib-1.0-SNAPSHOT.jar

So, this installs an empty jar pretending to be clojure-contrib. This
is, of course, completely broken behavior. The next leiningen build
grabs this thinking it's getting the real deal and completely croaks.

The problem appears to be that the ant build puts it's build products
into ./classes, but maven expects to find such things in
./target/classes, hence nothing to put in the JAR. (and since the JAR
already built by ant is in ./, not in ./target maven can't just grab
that.

Summary:

I've tried three different ways to get this to work and failed. What
am I overlooking? The nightly builds exist, so clearly this must be
working for someone, just not me.

Is it really this broken? If it really is this broken, how about
having our build.xml follow maven conventions for build products? Or
how about overriding the maven defaults in pom.xml to be in sync with
what ant is actually doing?

Thankful for any pointers,
Ben

dysinger

unread,
Dec 13, 2009, 5:15:01 PM12/13/09
to Clojure
I highly recommend you use the snapshots on build.clojure.org. Lein
already has build.clojure.org snapshots in it's repo list. You don't
need to do anything more than put

:dependencies [[org.clojure/clojure "1.1.0-master-SNAPSHOT"]
[org.clojure/clojure-contrib "1.1.0-master-SNAPSHOT"]]

in your project.clj

-Tim

B Smith-Mannschott

unread,
Dec 14, 2009, 1:13:25 AM12/14/09
to clo...@googlegroups.com
On Sun, Dec 13, 2009 at 23:15, dysinger <t...@dysinger.net> wrote:
> I highly recommend you use the snapshots on build.clojure.org.  Lein
> already has build.clojure.org snapshots in it's repo list.  You don't
> need to do anything more than put
>
>  :dependencies [[org.clojure/clojure "1.1.0-master-SNAPSHOT"]
> [org.clojure/clojure-contrib "1.1.0-master-SNAPSHOT"]]
>
> in your project.clj

It seems that I wasn't sufficiently clear. I have made changes [1] [2]
to clojure-contrib that are not in master. What I'm building amounts
to a personal fork of clojure-contrib. Once my CA is in and it becomes
time to propose these changes for inclusion, I'll be in a better
position to do so if they've actually seen some use (i.e. by me).

[1] http://wiki.github.com/bpsm/clojure-contrib/about-branch-ducks-byte
[2] http://github.com/bpsm/clojure-contrib/commits/ducks-read-forms

// Ben

Chas Emerick

unread,
Dec 14, 2009, 5:40:51 AM12/14/09
to clo...@googlegroups.com
The poms in clojure and clojure-contrib are not currently suitable for
installing/deploying the produced artifacts as-is (something that I
keep meaning to work on). We continue to rely upon in-house builds,
which I deploy using deploy:deploy-file along with tweaked pom files
-- you can do the same thing for your in-house deployments (or local
installation).

I presume the artifacts on build.clojure.org are deployed in much the
same way, although scripted, or perhaps there's some hudson magic
going on.

- Chas
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@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+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

Rob Wolfe

unread,
Dec 14, 2009, 8:34:09 AM12/14/09
to clo...@googlegroups.com
B Smith-Mannschott <bsmit...@gmail.com> writes:

> On Sun, Dec 13, 2009 at 23:15, dysinger <t...@dysinger.net> wrote:
>> I highly recommend you use the snapshots on build.clojure.org. �Lein
>> already has build.clojure.org snapshots in it's repo list. �You don't
>> need to do anything more than put
>>
>> ďż˝:dependencies [[org.clojure/clojure "1.1.0-master-SNAPSHOT"]
>> [org.clojure/clojure-contrib "1.1.0-master-SNAPSHOT"]]
>>
>> in your project.clj
>
> It seems that I wasn't sufficiently clear. I have made changes [1] [2]
> to clojure-contrib that are not in master. What I'm building amounts
> to a personal fork of clojure-contrib. Once my CA is in and it becomes
> time to propose these changes for inclusion, I'll be in a better
> position to do so if they've actually seen some use (i.e. by me).
>
> [1] http://wiki.github.com/bpsm/clojure-contrib/about-branch-ducks-byte
> [2] http://github.com/bpsm/clojure-contrib/commits/ducks-read-forms
>
> // Ben

It seems that everyone uses homemade pom.xml. I fully agree that having
standard one where "mvn install" will just work would be great.
I'm not really an expert on maven (and to be honest don't want to be),
but I managed to create something like that and indeed "mvn install" works
for me.
So here it is pom.xml and two descriptors for jars:

# clojure-jar.xml

<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>
<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.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-contrib</artifactId>
<name>clojure-contrib</name>
<version>1.0-SNAPSHOT</version>
<url>http://clojure.org/</url>
<packaging>pom</packaging>

<description>Clojure user contributions 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>
<jarfile>clojure-contrib-${project.version}</jarfile>
<slimjarfile>clojure-contrib-slim-${project.version}</slimjarfile>
</properties>

<dependencies>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>clojure-lang</artifactId>
<version>1.1.0-alpha-SNAPSHOT</version>
</dependency>
</dependencies>

<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>${src}</sourceDirectory>
<outputDirectory>${build}</outputDirectory>

<resources>
<resource>
<directory>${src}</directory>
</resource>
</resources>

<plugins>

<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4</version>

<executions>
<execution>
<id>copy-clojure</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${build}</outputDirectory>
<resources>
<resource>
<directory>${src}</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>compile-classes</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<!-- automatically creates the classpath using all project
dependencies,
also adding the project build directory -->
<classpath/>
<argument>-Dclojure.compile.path=${build}</argument>

<argument>clojure.lang.Compile</argument>
<argument>clojure.contrib.pprint.ColumnWriter</argument>
<argument>clojure.contrib.pprint.PrettyWriter</argument>
<argument>clojure.contrib.fnmap.PersistentFnMap</argument>
<argument>clojure.contrib.condition.Condition</argument>
<argument>clojure.contrib.jmx.Bean</argument>
</arguments>
</configuration>
</execution>

<execution>
<id>compile-clojure</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<!-- automatically creates the classpath using all project
dependencies,
also adding the project build directory -->
<classpath/>
<argument>-Dclojure.compile.path=${build}</argument>
<argument>-Djava.awt.headless=true</argument>

<argument>clojure.lang.Compile</argument>

<argument>clojure.contrib.accumulators</argument>
<argument>clojure.contrib.agent-utils</argument>
<argument>clojure.contrib.classpath</argument>
<argument>clojure.contrib.combinatorics</argument>
<argument>clojure.contrib.command-line</argument>
<argument>clojure.contrib.complex-numbers</argument>
<argument>clojure.contrib.cond</argument>
<argument>clojure.contrib.condition</argument>
<argument>clojure.contrib.core</argument>
<argument>clojure.contrib.dataflow</argument>
<argument>clojure.contrib.datalog</argument>
<argument>clojure.contrib.datalog.database</argument>
<argument>clojure.contrib.datalog.literals</argument>
<argument>clojure.contrib.datalog.magic</argument>
<argument>clojure.contrib.datalog.rules</argument>
<argument>clojure.contrib.datalog.softstrat</argument>
<argument>clojure.contrib.datalog.util</argument>
<argument>clojure.contrib.def</argument>
<argument>clojure.contrib.duck-streams</argument>
<argument>clojure.contrib.error-kit</argument>
<argument>clojure.contrib.except</argument>
<argument>clojure.contrib.mock</argument>
<argument>clojure.contrib.mock.test-adapter</argument>
<argument>clojure.contrib.fcase</argument>
<argument>clojure.contrib.find-namespaces</argument>
<argument>clojure.contrib.fnmap</argument>
<argument>clojure.contrib.gen-html-docs</argument>
<argument>clojure.contrib.generic</argument>
<argument>clojure.contrib.generic.arithmetic</argument>
<argument>clojure.contrib.generic.collection</argument>
<argument>clojure.contrib.generic.comparison</argument>
<argument>clojure.contrib.generic.functor</argument>
<argument>clojure.contrib.generic.math-functions</argument>
<argument>clojure.contrib.graph</argument>
<argument>clojure.contrib.greatest-least</argument>
<argument>clojure.contrib.import-static</argument>
<argument>clojure.contrib.jar</argument>
<argument>clojure.contrib.java-utils</argument>
<argument>clojure.contrib.javadoc.browse</argument>
<argument>clojure.contrib.javadoc.browse-ui</argument>
<argument>clojure.contrib.jmx</argument>
<argument>clojure.contrib.json.read</argument>
<argument>clojure.contrib.json.write</argument>
<argument>clojure.contrib.lazy-seqs</argument>
<argument>clojure.contrib.lazy-xml</argument>
<argument>clojure.contrib.macro-utils</argument>
<argument>clojure.contrib.macros</argument>
<argument>clojure.contrib.map-utils</argument>
<argument>clojure.contrib.math</argument>
<argument>clojure.contrib.miglayout</argument>
<argument>clojure.contrib.miglayout.internal</argument>
<argument>clojure.contrib.mmap</argument>
<argument>clojure.contrib.monads</argument>
<argument>clojure.contrib.ns-utils</argument>
<argument>clojure.contrib.pprint.ColumnWriter</argument>
<argument>clojure.contrib.pprint.PrettyWriter</argument>
<argument>clojure.contrib.pprint</argument>
<argument>clojure.contrib.pprint.utilities</argument>
<argument>clojure.contrib.probabilities.finite-distributions</argument>
<argument>clojure.contrib.probabilities.monte-carlo</argument>
<argument>clojure.contrib.probabilities.random-numbers</argument>
<argument>clojure.contrib.prxml</argument>
<argument>clojure.contrib.repl-ln</argument>
<argument>clojure.contrib.repl-utils</argument>
<argument>clojure.contrib.seq-utils</argument>
<argument>clojure.contrib.server-socket</argument>
<argument>clojure.contrib.set</argument>
<argument>clojure.contrib.shell-out</argument>
<argument>clojure.contrib.singleton</argument>
<argument>clojure.contrib.sql</argument>
<argument>clojure.contrib.sql.internal</argument>
<argument>clojure.contrib.str-utils</argument>
<argument>clojure.contrib.stream-utils</argument>
<argument>clojure.contrib.swing-utils</argument>
<argument>clojure.contrib.trace</argument>
<argument>clojure.contrib.types</argument>
<argument>clojure.contrib.with-ns</argument>
<argument>clojure.contrib.zip-filter</argument>
<argument>clojure.contrib.zip-filter.xml</argument>
</arguments>
</configuration>
</execution>

<execution>
<id>test-contrib</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>-Djava.security.policy=config/jmx.policy</argument>

<argument>clojure.main</argument>

<argument>-e</argument>
<argument>(ns test (:require [clojure.contrib [test-contrib :as main]])) (main/run)</argument>

</arguments>
</configuration>
</execution>

</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>test-contrib</id>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>!!! For testing use integration-test phase !!!</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>clojure-contrib-jar</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>${jarfile}</finalName>
<outputDirectory>.</outputDirectory>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
<manifestEntries>
<Class-Path>.</Class-Path>
</manifestEntries>
</archive>
<descriptors>
<descriptor>clojure-contrib-jar.xml</descriptor>
</descriptors>
</configuration>
</execution>

<execution>
<id>slim-jar</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>${slimjarfile}</finalName>
<outputDirectory>.</outputDirectory>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
<manifestEntries>
<Class-Path>.</Class-Path>
</manifestEntries>
</archive>
<descriptors>
<descriptor>contrib-slim-jar.xml</descriptor>
</descriptors>
</configuration>
</execution>

</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>skip-install</id>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>!!! Don't use default install phase !!!</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>install-clojure-contrib</id>
<phase>install</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>${jarfile}.jar</file>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<packaging>jar</packaging>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<executions>
<execution>
<id>clean-clojure-contrib</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<filesets>
<fileset>
<directory>.</directory>
<includes>
<include>${jarfile}.jar</include>
<include>${slimjarfile}.jar</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>

HTH,
Rob

DTH

unread,
Dec 13, 2009, 6:18:40 PM12/13/09
to Clojure
On Dec 13, 9:17 pm, B Smith-Mannschott <bsmith.o...@gmail.com> wrote:
> Summary:
>
> I've tried three different ways to get this to work and failed. What
> am I overlooking? The nightly builds exist, so clearly this must be
> working for someone, just not me.

mvn install:install-file -DpomFile=pom.xml -Dfile=clojure-contrib.jar

The same works for clojure itself; just change the jar name.

I fear I can't speak for your other questions...

As dysinger said, if you're using lein to build your projects, you
don't actually _have_ to install your own clojure or clojure-contrib,
and using the snapshots from build.clojure.org means there's less risk
of others running in to build problems if they try to build your
project from scratch.

-DTH

DTH

unread,
Dec 14, 2009, 7:09:34 AM12/14/09
to Clojure
On Dec 13, 9:17 pm, B Smith-Mannschott <bsmith.o...@gmail.com> wrote:
>
> Summary:
>
> I've tried three different ways to get this to work and failed. What
> am I overlooking? The nightly builds exist, so clearly this must be
> working for someone, just not me.
>

mvn install:install-file -DpomFile=pom.xml -Dfile=clojure-contrib.jar

seems to work for me with local builds; the same works for clojure
itself.

-DTH

B Smith-Mannschott

unread,
Dec 15, 2009, 5:12:07 AM12/15/09
to clo...@googlegroups.com
Rob, DTH,

Thanks for the responses. I guess that's more or less what I feared. I
had hoped that I was overlooking something. I'll just put a little
script on my integration branch which calls install:install-file with
the proper arguments. (The pom.xml solution is too great a violation
of DRY for my taste.)

// Ben
Reply all
Reply to author
Forward
0 new messages