While doing some recent work on a Facebook app I've been playing around with as a testbed for familiarizing myself with Facebook's API, Google App Engine and Clojure, I ran into the problem that I was copying and pasting my Ant setup for compiling and testing my Clojure code. This I did not feel very good about. The reason was that, though it was easy enough to just call out to <java></java> to run clojure.lang.Compile and execute the tests, there was always extra work to get the build failing when it should, especially in the case of the tests. It made me really yearn for a native Ant task that could handle the compilation and testing of Clojure code.
Thus was born Clojure Ant Tasks.
There isn't much to say about them. They pretty much do what they claim to, compile and test Clojure code. One nice thing about them is that they are written in Clojure, using gen-class. I imagine this will make it much easier to keep in sync and take advantage of future Clojure updates. Currently, they support Cojure 1.0 and the Clojure 1.0-compatible Clojure-Contrib tag. The reason is that I had to choose between supporting clojure.contrib.test-is or clojure.test and I felt it was better to stick to 1.0 for now, since that is more likely to be used in production. If there is demand for it, I can look at supporting both via a "version" attribute or something.
Both the compilation and test tasks support <namespace></namespace> elements and <fileset?</fileset>'s. One benefit to supporting both is that it provides the ability to specifiy compilation order while at the same time providing the flexibility and convenience <fileset></fileset>'s offer. For instance, if all of your code lives in "src" and has no dependencies on the order in which it is compiled other than a single gen-class'ed namespace that must be compiled first, you can do this:
<clojure-compile>
<classpath>
<path refid="sources.and.classes"></path>
</classpath>
<namespace>com.foo.genclassed.ns</namespace>
<fileset dir="src" includes="**/*.clj"></fileset>
</clojure-compile>
Here, com.foo.genclassed.ns will be compiled first and, subsequently, every other *.clj file in src will be compiled.
For more information and to see the format of the tasks, check out the README. Feature requests, bug reports and all other feedback are welcome over on GitHub. Feel free to either message me or open a ticket directly.
Enjoy!