Index: /other-projects/trunk/gs3-webservices-democlient/build.xml
===================================================================
--- /other-projects/trunk/gs3-webservices-democlient/build.xml	(revision 15312)
+++ /other-projects/trunk/gs3-webservices-democlient/build.xml	(revision 15313)
@@ -20,12 +20,21 @@
  <property name="build" value="${basedir}/build" />
  <property name="dist" value="${basedir}/dist" />
+
  <property name="QBRdata.rel.path" value="org/greenstone/gs3client/data" />
  <property name="dlservices.rel.path" value="org/greenstone/gs3client/dlservices" />
  <property name="gui.rel.path" value="org/greenstone/gs3client" />
  <property name="gs3services.rel.path" value="org/greenstone/gs3services" />
+
  <property name="exec.jar.name" value="GS3democlient.jar" /> <!-- name of the executable-->
- <property name="download.zip.name" value="gs3_webservices_democlient" />
+ <property name="gs3.files.jar" value="gs3_for_client.jar" />
  <property name="log4j.propFile" value="log4j.properties" />
+
+ <property name="dist.zip.name" value="gs3_webservices_democlient" />
  <property name="zip.excludes" value="dist/**,logs/**,gs3democlient.properties" />
+ <property name="dist.dir.name" value="gs3-webservices-democlient" />
+
+ <!-- svn paths for getting copies of the latest version of source code -->
+ <property name="gs3forclient.svn.path" value="http://svn.greenstone.org/greenstone3/trunk/src/java/org/greenstone/gsdl3/util/"/>
+ <property name="check.java.version.svn.file" value="http://svn.greenstone.org/gli/trunk/CheckJavaVersion.java"/>
 
   <!-- ============ project classpath: everything in the lib folder =================== -->
@@ -58,5 +67,5 @@
 
 <!-- Main targets: to build the GS3 web services demo-client and to create the tar.gz file for downloading -->
-<target name="build-demo-client" description="Creates the jar distribution file" depends="compile-demo-client">
+<target name="build-demo-client" description="Creates the jar distribution file" depends="compile-demo-client,ensure-check-java-version">
   <mkdir dir="${basedir}/logs" /> <!-- Need a logs dir for outputting log4j stuff-->
   <delete file="${exec.jar.name}" /> <!--For now: Let's delete it first and do a fresh rebuild-->
@@ -76,5 +85,5 @@
 
 <!-- Compilation first ensures the existence of QBRdata.jar AND fedoraGS3.jar by checking whether these jars exist and if not, generating them. Then actual compilation of the GS3democlient starts. By now the QBRdata classes of the GS3democlient src folder would have been compiled, but that does not matter as javac only compiles when class files that are outdated or when they have not been generated yet.-->
-<target name="compile-demo-client" description="Compiles the GS3 demo-client" depends="ensure-QBRdata-jar,ensure-fedoraGS3-jar">
+<target name="compile-demo-client" description="Compiles the GS3 demo-client" depends="ensure-QBRdata-jar,ensure-fedoraGS3-jar,ensure-gs3-for-client">
     <javac srcdir="${democlient.rootdir}">
       <classpath refid="project.classpath"/>
@@ -84,5 +93,5 @@
 
 <!-- Cleaning targets -->
-<target name="clean-democlient" description="Removes all class files from the GS3demo-client">
+<target name="clean-democlient" description="Removes all class files from the GS3demo-client (includes the data package that is used to create QBRdata.jar)">
    <delete>
     <fileset dir="${democlient.src}" includes="**/*.class"/>
@@ -94,4 +103,65 @@
     <fileset dir="${fedorags3.src}" includes="**/*.class"/>
    </delete>
+</target>
+
+<!-- Explicit update. First make a directory and copy the old files in there (if they are present)-->
+<target name="update" description="Gets the latest version of CheckJavaVersion.java, and gs3-client-jar's files from Greenstone's SVN repository">
+   <delete>
+      <fileset dir="${basedir}" includes="CheckJavaVersion.*"/>
+   </delete>
+   <antcall target="update-check-java-version" />	
+   <antcall target="update-gs3-for-client" />
+</target>
+
+<target name="ensure-check-java-version" description="Ensures the file CheckJavaVersion.java is there">
+    <condition property="check.java.version.exists">
+       <and>
+	<available file="${basedir}/CheckJavaVersion.java"/>
+        <available file="${basedir}/CheckJavaVersion.class"/>
+       </and>
+    </condition>
+    <antcall target="update-check-java-version" />
+</target>
+
+<target name="ensure-gs3-for-client" description="Ensures the ${gs3.files.jar} file of required Greenstone3 support files is there">
+    <condition property="gs3.for.client.exists">
+	<available file="${basedir}/lib/${gs3.files.jar}"/>
+    </condition>
+    <antcall target="update-gs3-for-client" />
+</target>
+
+
+<!-- "By default, files are only copied if the source file is newer than the destination file, or when the destination file does not exist. (However, you can explicitly overwrite files with the overwrite attribute.)" In other words, this method will only copy when necessary -->
+<target name="update-check-java-version" description="Gets the latest version of CheckJavaVersion.javafrom Greenstone's SVN repository" unless="check.java.version.exists">
+   <copy todir="${basedir}" flatten="true">
+    <resources>
+      <url url="${check.java.version.svn.file}"/>
+    </resources>
+  </copy>
+  <!-- compile it up: specifying the file to be compiled explicitly (sourcepath="")--> 
+  <javac sourcepath="" srcdir="${basedir}" destdir="${basedir}" >
+    <include name="**/CheckJavaVersion.java"/>
+  </javac>
+</target>
+
+<target name="update-gs3-for-client" description="Gets the latest version of the files needed to create ${gs3.files.jar} from Greenstone's SVN repository" unless="gs3.for.client.exists">
+  <mkdir dir="${basedir}/tmp" />
+  <echo>Getting java files GSXML, XMLConverter, GSPath and MyNodeList from Greenstone's SVN repository (${gs3forclient.svn.path}). Compiling and jarring them up into ${gs3.files.jar}...</echo>
+  <copy todir="${basedir}/tmp" flatten="true">
+    <resources>
+      <url url="${gs3forclient.svn.path}/GSXML.java"/>
+      <url url="${gs3forclient.svn.path}/XMLConverter.java"/>
+      <url url="${gs3forclient.svn.path}/GSPath.java"/>
+      <url url="${gs3forclient.svn.path}/MyNodeList.java"/>
+    </resources>
+  </copy>
+  <!-- compile it up: specifying the file to be compiled explicitly --> 
+  <javac srcdir="${basedir}/tmp" destdir="${basedir}/tmp" >
+    <classpath refid="project.classpath"/>
+    <include name="**/*.java"/>
+  </javac>	
+  <!-- jar it up (without the java files), placing the jar in the lib folder -->	
+  <jar destfile="lib/${gs3.files.jar}" basedir="tmp/" excludes="tmp/*.java" />
+  <delete dir="tmp" />
 </target>
 
@@ -132,7 +202,4 @@
 </target>
 
-<target name="update-gs3forclient.jar" description="Will update the class files in ${basedir}/lib/gs3_for_client.jar using svn to the latest versions of those files in Greenstone3's svn repository">
-</target>
-
 <!-- Targets that check for and ensure the existence of project-specific jar files -->
 <target name="check-QBRdata-jar" description="Checks for existence of dependency file QBRdata.jar">
@@ -169,16 +236,21 @@
 <!-- User input for generating compressed output file for one of the chosen file types. A choice of zip, tar.gz (tar gzip), or tar.bz2 (tar bzip)-->
 <target name="create-targzip" if="zip.type" description="User chose to create a tar.gz file of the project">
-    <tar destfile="${dist}/${download.zip.name}.tar.gz" basedir="${basedir}" compression="gzip" excludes="${zip.excludes}" longfile="gnu" /> 
+   <tar destfile="${dist}/${dist.zip.name}.tar.gz" compression="gzip" longfile="gnu"> 
+     <tarfileset dir="${basedir}" prefix="${dist.dir.name}" excludes="${zip.excludes}" />
+   </tar>
+   <echo>If the filepaths are longer than 100 characters, GNU compatible tar commands are necessary to untar the tar.gz</echo>
+</target>
+
+<target name="create-tarbzip" if="zip.type" description="User chose to create a tar.bz2 file of the project">
+    <tar destfile="${dist}/${dist.zip.name}.tar.bz2" compression="bzip2" longfile="gnu"> 
+      <tarfileset dir="${basedir}" prefix="${dist.dir.name}" excludes="${zip.excludes}" />
+    </tar>
     <echo>If the filepaths are longer than 100 characters, GNU compatible tar commands are necessary to untar the tar.gz</echo>
 </target>
 
-<target name="create-tarbzip" if="zip.type" description="User chose to create a tar.bz2 file of the project">
-    <tar destfile="${dist}/${download.zip.name}.tar.bz2" basedir="${basedir}" compression="bzip2" excludes="${zip.excludes}" longfile="gnu" /> 
-    <echo>If the filepaths are longer than 100 characters, GNU compatible tar commands are necessary to untar the tar.gz</echo>
-</target>
-
 <target name="create-zip" if="zip.type" description="User chose to create a zip file of the project">
-     <zip basedir="${basedir}" destfile="${dist}/${download.zip.name}.zip" 
-	excludes="${zip.excludes}" />
+    <zip destfile="${dist}/${dist.zip.name}.zip">
+       <zipfileset dir="${basedir}" prefix="${dist.dir.name}" excludes="${zip.excludes}" />
+    </zip>
 </target>
 
