Hello Jason,

Am 03.04.2009 um 14:18 schrieb Jason Warner:


I'd be interested in seeing the ivy+ant solution. We use maven2 at
work and there are obvious pros and cons. With clojure, part of the
pain is initial setup and config. Maven2/ant+ivy might really help
that. Post when you get a chance...am very interested.

I also had a look at ivy, yesterday. I stitched together a proof of
concept using the ivy tutorial example. In particular I wanted to
know how difficult it is to setup a repository to provide my projects
as possible dependencies.

There are three files attached. The ivysettings file defines the
repositories to search for a dependency. In this case this is my
site, the nightly build site on tapestry by Howard Lewis Ship
and the (somehow) default ibiblio repository. The ivy.xml defines
two dependencies for our example project: of course clojure
and my lazymap library (as I said: I wanted to test the distribution
as dependency). The ant script downloads ivy, resolves the
dependencies and compiles a small example program.

After putting all files into a temporary directory and running ant,
I executed the example program:

ceres:~/tmp/ivy-test% java -cp classes:lib/clojure-lang-1.0- SNAPSHOT.jar:lib/lazymap-2.2.0.jar org.example.hello
5
Will now print :a => 5
7
Will now print :b => 7

Success! :) Now some ivy and ant gurus, might have a look
and tell me, what I did wrong and what could be improved.
If this style is ok, that would be perfect, since I don't want to
set up a whole maven thing. (which I have to understand first)
This setup on the other hand is quite simple, and would work
for me perfectly.

If I understand this correctly, one could also use eg. github or
bitbucket to distribute software since one can specify arbitrary
URLs. The checksum of the commit could be used as revision.
But this is only an idea. I didn't test that one.

Sincerely
Meikel

<project xmlns:ivy="antlib:org.apache.ivy.ant" name="test-ivy" default="aot">
    <property name="ivy.install.version" value="2.1.0-rc1" />
    <property name="ivy.jar.dir" value="${basedir}/ivy" />
    <property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" />

    <property name="build" value="classes"/>
    <property name="src" value="src"/>

    <target name="download-ivy" unless="skip.download">
        <mkdir dir="${ivy.jar.dir}"/>
        <get src="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar";
            dest="${ivy.jar.file}" usetimestamp="true"/>
    </target>

    <target name="install-ivy" depends="download-ivy" description="--> install ivy">
        <path id="ivy.lib.path">
            <fileset dir="${ivy.jar.dir}" includes="*.jar"/>
        </path>
        <taskdef resource="org/apache/ivy/ant/antlib.xml"
            uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
    </target>

    <target name="resolve" depends="install-ivy" description="--> retrieve dependencies with ivy">
        <ivy:retrieve />
    </target>

    <target name="generate-src" description="--> generate test program">
        <mkdir dir="${src}/org/example"/>
        <echo file="${src}/org/example/hello.clj">
            (clojure.core/ns org.example.hello
              (:require [de.kotka.lazymap :as lazymap])
              (:gen-class))

            (defn -main
              [&amp; args]
              (let [report  #(do (println %) %)
                    the-map (lazymap/lazy-hash-map :a (report 5) :b (report 7))]
                (println "Will now print :a =>" (the-map :a))
                (println "Will now print :b =>" (the-map :b))))
        </echo>
    </target>

    <target name="aot" depends="resolve,generate-src" description="--> compile clojure">
        <mkdir dir="${build}"/>
        <java classname="clojure.lang.Compile">
            <classpath>
                <path location="${build}"/>
                <path location="${src}"/>
                <fileset dir="lib" includes="*.jar"/>
            </classpath>
            <sysproperty key="clojure.compile.path" value="${build}"/>
            <arg value="org.example.hello"/>
        </java>
    </target>
</project>

<ivy-module version="2.0">
    <info organisation="de.kotka" module="test-ivy"/>
    <dependencies>
        <dependency org="org.clojure" name="clojure-lang" rev="1.0-SNAPSHOT"/>
        <dependency org="de.kotka" name="lazymap" rev="2.2.0"/>
    </dependencies>
</ivy-module>
<ivysettings>
    <settings defaultResolver="chained"/>
    <resolvers>
        <chain name="chained" returnFirst="true">
            <url name="kotka.de">
                <ivy pattern="http://kotka.de/ivy/[module]/ivy-[revision].xml"/>
                <artifact pattern="http://kotka.de/ivy/[module]/[artifact]-[revision].[ext]"/>
            </url>
            <ibiblio name="org.clojure" m2compatible="true" root="http://tapestry.formos.com/maven-snapshot-repository/"/>
            <ibiblio name="ibiblio" m2compatible="true"/>
        </chain>
    </resolvers>
</ivysettings>

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to