Hi Bradford,

Am 08.04.2009 um 21:31 schrieb Bradford Cross:

I heard some chatter yesterday on #clojure about using Ivy with Clojure.

Yes. I'm working on marrying Clojure and Ivy. So far with, IMHO,
great success. I set up a little ivy repo with clojure and contrib.
The clojure module has the following configurations:

- default => AOT compiled clojure jar
- dev => the previous + a source jar
- slim => Java source compiled, clojure sources as is

The contrib module has (roughly) one configuration per unit, ie.
def, pprint, stacktrace...., with the following exceptions:

- I grouped together the scattered math stuff into a math configuration.
- generic and types depend on each other so their combined into
  the generic configuration.

Similar to clojure a source configuration is included, which adds
a source jar to the dependencies

This allows very fine-grained control of what is needed. So if you want
only def, you only download a 13k not 2.5M.

To use this setup, you only have to specify the dependencies in
your ivy.xml and ivysettings.xml files. Here an example:

ivysettings.xml:
<ivysettings>
    <include url="${ivy.default.settings.dir}/ivysettings.xml"/>
    <include url="http://kotka.de/ivy/ivysettings.xml"/>
</ivysettings>

The first line sucks in the default configuration, the second tells
Ivy how to resolve the clojure and contrib dependencies.

ivy.xml:
<ivy-module version="2.0">
    ... <!-- project specific stuff here -->

    <dependencies>
<dependency org="org.clojure" name="clojure-lang" rev="1.0.0" conf="default"/> <dependency org="org.clojure" name="clojure-contrib" rev="1.0.0" conf="default->def"/>
    </dependencies>
</ivy-module>

Now you only have to integrate Ivy with your build system. It can
be done very easily with ant, but may also be used standalone,
eg. with make.

Here you can see an example how I integrated Ivy with my lazymap project.

    http://bitbucket.org/kotarak/lazymap/src/

It is avalaible via the kotka.de ivysettings as

<dependency org="de.kotka" name="lazymap" rev="2.2.0" conf="default"/>

I can't speak for SLIME, but VimClojure can be simply started with the
resolved jars from lib directory in the classpath.

-I download lots of little projects things from github and i want to munge them all together for my app. This means I need to build jars (some with ant, otehrs with maven, etc.) and in other cases I want to depend directly on the .clj files using clojures namespace-to-dir- structure conventions. So there are a couple different ways to build of the classpath - one for .clj and one for .jar.

I'm not sure, that Ivy can help in the general case, where you have to build the dependencies. I think it only downloads the files and makes them available. In particular it doesn't seem to handle subdirectories. So vanilla clj might not
work.

-Many projects also have their own lib foler - with both jars and cljs, so I need to pick those deps up transatively.

This is a breeze with Ivy. It must say, that this just works beautifully. The dependencies either work with Ivy or with Maven and are resolved transitively. You can also mirror dependencies locally, to make sure they don't go away.

-The work in the Clojure community is proceeding very fast, so I'd like updating all the projects from git to be automated as well.

This could be easily done with Ivy. Check out the dependencies you need.
Add an ivy.xml and a custom build script for ant. Then you can create a
master build.xml, which iterates through all dependencies in the right order
to pull changes, rebuild and publish into your local repository.

I actually haven't set up production version of such a structure but I tried
around and it worked without problems. The Ivy documentation has some
tutorial on this.

So what is a good solution to these problems? Perhaps it would be cool to build some git/maven/lancet aware infrastructure to do this refreshing of deps, building the deps, and building up the classpath. It may also be good to configure .emacs to be able to load projects and rebuild the classpath dynamically based on lancet build files - much in the way that intelliJ or eclipse load projects from ant .builds or maven poms.

I'm not sure for bigger setups, but for my current needs Ivy Just Works. So
I think it's certainly worth a look.

Sincerely
Meikel

PS: May changes to clojure and contrib are attached as diffs. They add the
Ivy information and a new build+ivy.xml for ant.

Attachment: clojure-ivy2.diff
Description: Binary data

 

Attachment: contrib-ivy2.diff
Description: Binary data



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

Reply via email to