I've enclosed a patch to build.xml that lets it stand alone without  
the "precompile.clj" helper file we're using currently. The patched  
build.xml writes the Clojure compile script to a build directory at  
build time based on a new ant property whose value is the list of libs  
to compile. I think this will be easier to maintain and makes for a  
simpler example to follow in building applications that include  
compiled Clojure libs.

The generated script has build properties expanded inline rather than  
communicated through System/getProperty. The patched build.xml also  
corrects/simplifies the example in the project description.

Note: svn diff's notion of removing a file is to delete all its lines,  
so I've removed the part that "patches" src/clj/precompile.clj. If  
this patch is adopted, src/clj/precompile.clj should be removed.

--Steve

Index: build.xml
===================================================================
--- build.xml   (revision 1105)
+++ build.xml   (working copy)
@@ -1,51 +1,59 @@
  <project name="clojure" default="jar">

-       <description>
-               Build with "ant jar" and then start the REPL
-               via "java -cp clojure.jar clojure.lang.Repl src/boot.clj".
-       </description>
+  <description>
+    Build with "ant jar", then start the REPL via "java -jar  
clojure.jar".
+  </description>

-       <property name="src" location="src"/>
-       <property name="jsrc" location="${src}/jvm"/>
-       <property name="cljsrc" location="${src}/clj"/>
-       <property name="build" location="classes"/>
-       <property name="clojure_jar" location="clojure.jar"/>
-       <property name="bootclj" location="${cljsrc}/clojure/core.clj"/>
-       <property name="precompile" location="${cljsrc}/precompile.clj"/>
+  <property name="src" location="src"/>
+  <property name="jsrc" location="${src}/jvm"/>
+  <property name="cljsrc" location="${src}/clj"/>
+  <property name="build" location="build"/>
+  <property name="compile_clj" location="${build}/compile.clj"/>
+  <property name="classes" location="${build}/classes"/>
+  <property name="clojure_jar" location="clojure.jar"/>
+  <property name="libs" value="clojure.core clojure.set clojure.xml
+                               clojure.zip clojure.inspector"/>

-       <target name="init">
-               <tstamp/>
-               <mkdir dir="${build}"/>
-       </target>
+  <target name="init">
+    <tstamp/>
+    <mkdir dir="${classes}"/>
+  </target>

-       <target name="compile" depends="init"
-               description="Compile Java sources.">
-               <javac srcdir="${jsrc}" destdir="${build}" 
includeJavaRuntime="yes"  
debug="true" target="1.5"/>
-       </target>
+  <target name="compile-java" depends="init"
+          description="Compile Java sources.">
+    <javac srcdir="${jsrc}" destdir="${classes}"  
includeJavaRuntime="yes"
+           debug="true" target="1.5"/>
+  </target>

-       <target name="core" depends="compile"
-               description="Precompile Clojure core sources.">
-               <java classname="clojure.lang.Script"
-                      classpath="${build}:${cljsrc}">
-                        <sysproperty key="clojure.compile.path"  
value="${build}"/>
-                       <arg value="${precompile}"/>
-               </java>
-       </target>
+  <target name="compile-clojure" depends="compile-java"
+          description="Compile Clojure libs.">
+    <echo file="${compile_clj}" append="false">
+      (def libs '(${libs}))
+      (def compile-path "${classes}")
+      (printf "Compiling %d libs to %s\n" (count libs) compile-path)
+      (binding [*compile-path* compile-path]
+        (doseq [lib libs]
+          (compile lib)))
+    </echo>
+    <java classname="clojure.lang.Script" classpath="${classes}:$ 
{cljsrc}">
+      <arg value="${compile_clj}"/>
+    </java>
+  </target>

-       <target name="jar" depends="core"
-               description="Create jar file.">
-               <jar jarfile="${clojure_jar}" basedir="${build}">
-                       <!-- <fileset dir="${cljsrc}" includes="**/*.clj"/> -->
-                       <manifest>
-                               <attribute name="Main-Class" 
value="clojure.lang.Repl"/>
-                               <attribute name="Class-Path" value="."/>
-                       </manifest>
-               </jar>
-       </target>
+  <target name="jar" depends="compile-clojure"
+          description="Create jar file.">
+    <jar jarfile="${clojure_jar}" basedir="${classes}">
+      <!-- <fileset dir="${cljsrc}" includes="**/*.clj"/> -->
+      <manifest>
+        <attribute name="Main-Class" value="clojure.lang.Repl"/>
+        <attribute name="Class-Path" value="."/>
+      </manifest>
+    </jar>
+  </target>

-       <target name="clean"
-               description="Remove autogenerated files and directories.">
-               <delete dir="${build}"/>
-       </target>
+  <target name="clean"
+          description="Remove autogenerated files and directories.">
+    <delete dir="${build}"/>
+  </target>

  </project>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to