I wrote build.xml with the following content:
<project name="edn-extractor" default="jar">
<property name="src.dir" location="src" />
<property name="classes.dir" location="classes" />
<property name="jar.name" value="edn-extractor.jar" />
<path id="project.classpath">
<pathelement location="${src.dir}" />
<pathelement location="${classes.dir}" />
<fileset dir="lib">
<include name="**/*.jar" />
</fileset>
</path>
<target name="clean" description="Remove generated files.">
<delete dir="${classes.dir}" />
<delete file="${jar.name}" />
</target>
<target name="def-tasks">
<taskdef name="compile-clojure"
classname="com.ubermensch.ant.clojure.CompileTask"
classpath="lib/clojure.jar:lib/clojure-contrib.jar:lib/clojure-ant-tasks.jar"
/>
</target>
<target name="compile" depends="def-tasks">
<mkdir dir="${classes.dir}" />
<compile-clojure>
<classpath>
<path refid="project.classpath" />
</classpath>
</compile-clojure>
</target>
<target name="jar" depends="compile">
<jar jarfile="${jar.name}" basedir="${classes.dir}">
<fileset dir="${src.dir}">
<include name="**/*.clj" />
</fileset>
</jar>
</target>
</project>
And I have a simple directory structure:
# find .
./build.xml
./src
./src/edn
./src/edn/main.clj
./lib
./lib/clojure-contrib.jar
./lib/clojure.jar
./lib/clojure-ant-tasks.jar
Here is the content of main.clj:
(ns edn.main
(:gen-class))
(defn -main
[greetee]
(println (str "Hello " greetee "!")))
Then if I run ant, I get:
Buildfile: build.xml
def-tasks:
BUILD FAILED
java.lang.ExceptionInInitializerError
at clojure.lang.Namespace.<init>(Namespace.java:32)
at clojure.lang.Namespace.findOrCreate(Namespace.java:122)
at clojure.lang.Var.internPrivate(Var.java:94)
at com.ubermensch.ant.clojure.base_task.<clinit>(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:583)
at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:228)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
at org.apache.tools.ant.Main.runBuild(Main.java:758)
at org.apache.tools.ant.Main.startAnt(Main.java:217)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Caused by: java.lang.RuntimeException: java.io.FileNotFoundException:
Could not locate clojure/core__init.class or clojure/core.clj on
classpath:
at clojure.lang.RT.<clinit>(RT.java:295)
... 25 more
Caused by: java.io.FileNotFoundException: Could not locate
clojure/core__init.class or clojure/core.clj on classpath:
at clojure.lang.RT.load(RT.java:402)
at clojure.lang.RT.load(RT.java:371)
at clojure.lang.RT.doInit(RT.java:406)
at clojure.lang.RT.<clinit>(RT.java:292)
... 25 more
Total time: 0 seconds
Either of clojure/core.clj and clojure/core__init.class is on
classpath, I think. What am I doing wrong?
Either of clojure/core.clj and clojure/core__init.class is on
classpath, I think. What am I doing wrong?
> Hmmm ... This builds fine for me (with the inclusion of
> <namespace>edn.main</namespace> in the <compile-clojure /> element). I've
> uploaded what I have here so you can try it on your machine:
I have just pasted this too.
> http://github.com/jmcconnell/test-clojure-ant-project/tree/master
It seems to be identical.
> What versions of Clojure and Clojure-Contrib are you using?
The freshest ones.
> Also, which version of Ant?
ivan@inote edn-extract % ant -version
Apache Ant version 1.7.1 compiled on August 29 2009
Here is the debug output: http://pastebin.com/m6306a855
I have just tried "ant -lib lib" and everithing's ok.
ivan@inote edn-extract % java -cp lib/clojure.jar:edn-extractor.jar
edn.main "Big Brother"
Hello Big Brother!
I'm curious what may be the reason!
2009/8/30 J. McConnell <jdo...@gmail.com>:
The freshest ones.
> What versions of Clojure and Clojure-Contrib are you using?
I'm curious what may be the reason!
> The Ant tasks have only been tested against Clojure 1.0, since I assumed
> that's what most people would be using in a production context.
For my personal projects the HEAD version is stable enough. :)
> I am
> thinking about going the Contrib route and tagging a 1.0-compatible version
> and updating everything to work against HEAD. Feel free to watch the repo on
> GitHub if you'd be interested in that.
OK, thank you!