Index: /greenstone3/trunk/build.xml
===================================================================
--- /greenstone3/trunk/build.xml	(revision 16950)
+++ /greenstone3/trunk/build.xml	(revision 16951)
@@ -647,30 +647,48 @@
   <target name="prepare-tomcat" depends="init,setup-proxy" if="tomcat.islocal">
 
-    <!-- check that packages dir is there -->
-    <mkdir dir="${packages.home}"/>
-    <get src="http://www.greenstone.org/gs3files/${tomcat.version}.zip"
-      dest="${packages.home}/${tomcat.version}.zip"
-      usetimestamp="true"/>
-    <unzip src="${packages.home}/${tomcat.version}.zip" 
-      dest="${packages.home}"/>
-    <get src="http://www.greenstone.org/gs3files/${tomcat.version}-compat.zip"
-      dest="${packages.home}/${tomcat.version}-compat.zip"
-      usetimestamp="true"/>
-    <unzip src="${packages.home}/${tomcat.version}-compat.zip" 
-      dest="${packages.home}"/>
-    <!-- delete any existing tomcat -->
-    <delete dir="${packages.home}/tomcat"/>
-    <move todir="${packages.home}/tomcat">
-      <fileset dir="${packages.home}/${tomcat.version}"/>
-    </move>
-    <copy file="${basedir}/resources/tomcat/setclasspath.bat"
-      tofile="${packages.home}/tomcat/bin/setclasspath.bat"
-      overwrite="true"/>
-    <copy file="${basedir}/resources/tomcat/setclasspath.sh"
-      tofile="${packages.home}/tomcat/bin/setclasspath.sh"
-      overwrite="true"/>
-    <!-- make sure we have execute permission for the .sh files -->
-    <chmod dir="${packages.home}/tomcat/bin" perm="ugo+rx" 
-      includes="*.sh"/>   
+    <if>
+      <bool>
+        <not><available file="${packages.home}/tomcat/.flagfile"/></not>
+      </bool>
+
+      <!-- check that packages dir is there -->
+      <mkdir dir="${packages.home}"/>
+      <get src="http://www.greenstone.org/gs3files/${tomcat.version}.zip"
+        dest="${packages.home}/${tomcat.version}.zip"
+        usetimestamp="true"/>
+      <unzip src="${packages.home}/${tomcat.version}.zip" 
+        dest="${packages.home}"/>
+      <get src="http://www.greenstone.org/gs3files/${tomcat.version}-compat.zip"
+        dest="${packages.home}/${tomcat.version}-compat.zip"
+        usetimestamp="true"/>
+      <unzip src="${packages.home}/${tomcat.version}-compat.zip" 
+        dest="${packages.home}"/>
+      <!-- delete any existing tomcat -->
+      <delete dir="${packages.home}/tomcat"/>
+      <move todir="${packages.home}/tomcat">
+        <fileset dir="${packages.home}/${tomcat.version}"/>
+      </move>
+      <copy file="${basedir}/resources/tomcat/setclasspath.bat"
+        tofile="${packages.home}/tomcat/bin/setclasspath.bat"
+        overwrite="true"/>
+      <copy file="${basedir}/resources/tomcat/setclasspath.sh"
+        tofile="${packages.home}/tomcat/bin/setclasspath.sh"
+        overwrite="true"/>
+      <!-- make sure we have execute permission for the .sh files -->
+      <chmod dir="${packages.home}/tomcat/bin" perm="ugo+rx" 
+        includes="*.sh"/>   
+
+      <echo file="${packages.home}/tomcat/.flagfile">
+        the timestamp of this file is the time that tomcat was extracted from the zip files.
+        it is used to figure out whether the files need to be refreshed or not in `ant prepare-tomcat`
+      </echo>
+
+      <else>
+        <echo>Tomcat has been prepared, will not prepare</echo>
+        <echo>Delete ${packages.home}/tomcat/.flagfile to force refresh</echo>
+      </else>
+
+    </if>
+
   </target>
   
@@ -767,12 +785,28 @@
   <!-- ======================= ant Targets ============================ --> 
   <target name="prepare-ant" depends="init">
-    <get src="http://www.greenstone.org/gs3files/apache-ant-1.7.0-bin.zip"
-      dest="${packages.home}/apache-ant-1.7.0-bin.zip"
-      usetimestamp="true"/>
-    <unzip src="${packages.home}/apache-ant-1.7.0-bin.zip"
-      dest="${packages.home}"/>
-    <move todir="${packages.home}/ant">
-      <fileset dir="${packages.home}/apache-ant-1.7.0"/>
-    </move>
+    <if>
+      <bool>
+        <not><available file="${packages.home}/ant/.flagfile"/></not>
+      </bool>
+
+      <get src="http://www.greenstone.org/gs3files/apache-ant-1.7.0-bin.zip"
+        dest="${packages.home}/apache-ant-1.7.0-bin.zip"
+        usetimestamp="true"/>
+      <unzip src="${packages.home}/apache-ant-1.7.0-bin.zip"
+        dest="${packages.home}"/>
+      <move todir="${packages.home}/ant">
+        <fileset dir="${packages.home}/apache-ant-1.7.0"/>
+      </move>
+      <echo file="${packages.home}/ant/.flagfile">
+        the timestamp of this file is the time that ant was extracted from the zip files.
+        it is used to figure out whether the files need to be refreshed or not in `ant prepare-ant`
+      </echo>
+
+      <else>
+        <echo>Ant has been prepared, will not prepare</echo>
+        <echo>Delete ${packages.home}/ant/.flagfile to force refresh</echo>
+      </else>
+
+    </if>
   </target>
 
@@ -780,30 +814,47 @@
 
   <target name="prepare-axis" depends="init">
-    <get src="http://www.greenstone.org/gs3files/${axis.zip.version}"
-      dest="${packages.home}/${axis.zip.version}"
-      usetimestamp="true"/>
-    <unzip src="${packages.home}/${axis.zip.version}"
-      dest="${packages.home}"/>
-    <move todir="${packages.home}/axis">
-      <fileset dir="${packages.home}/${axis.dir.version}"/>
-    </move>
-    <!-- install axis into greenstone web app -->
-    <copy todir="${web.lib}">
-      <fileset dir="${packages.home}/axis/webapps/axis/WEB-INF/lib">
-        <include name="*.jar"/>
-      </fileset>
-    </copy>
-    <copy todir="${web.home}">
-      <fileset dir="${packages.home}/axis/webapps/axis/">
-        <include name="*.jsp"/>
-        <include name="*.jws"/>
-      </fileset>
-    </copy>
-    <copy tofile="${web.home}/axis.html" file="${packages.home}/axis/webapps/axis/index.html"/>
-    <copy todir="${web.classes}">
-      <fileset dir="${packages.home}/axis/webapps/axis/WEB-INF/classes">
-        <include name="*.properties"/>
-      </fileset>
-    </copy>
+
+    <if>
+      <bool>
+        <not><available file="${packages.home}/axis/.flagfile"/></not>
+      </bool>
+
+      <get src="http://www.greenstone.org/gs3files/${axis.zip.version}"
+        dest="${packages.home}/${axis.zip.version}"
+        usetimestamp="true"/>
+      <unzip src="${packages.home}/${axis.zip.version}"
+        dest="${packages.home}"/>
+      <move todir="${packages.home}/axis">
+        <fileset dir="${packages.home}/${axis.dir.version}"/>
+      </move>
+      <!-- install axis into greenstone web app -->
+      <copy todir="${web.lib}">
+        <fileset dir="${packages.home}/axis/webapps/axis/WEB-INF/lib">
+          <include name="*.jar"/>
+        </fileset>
+      </copy>
+      <copy todir="${web.home}">
+        <fileset dir="${packages.home}/axis/webapps/axis/">
+          <include name="*.jsp"/>
+          <include name="*.jws"/>
+        </fileset>
+      </copy>
+      <copy tofile="${web.home}/axis.html" file="${packages.home}/axis/webapps/axis/index.html"/>
+      <copy todir="${web.classes}">
+        <fileset dir="${packages.home}/axis/webapps/axis/WEB-INF/classes">
+          <include name="*.properties"/>
+        </fileset>
+      </copy>
+      <echo file="${packages.home}/axis/.flagfile">
+        the timestamp of this file is the time that axis was extracted from the zip files.
+        it is used to figure out whether the files need to be refreshed or not in `ant prepare-axis`
+      </echo>
+
+      <else>
+        <echo>Axis has been prepared, will not prepare</echo>
+        <echo>Delete ${packages.home}/axis/.flagfile to force refresh</echo>
+      </else>
+
+    </if>
   </target>
 
@@ -1593,10 +1644,28 @@
 
   <target name="prepare-gdbm" depends="init" if="install.gdbm">
-    <get src="http://www.greenstone.org/gs3files/${gdbm.version}.tar.gz"
-      dest="${src.packages.home}/${gdbm.version}.tar.gz"  usetimestamp="true"/>
-    <untar compression= "gzip" src="${src.packages.home}/${gdbm.version}.tar.gz" dest="${src.packages.home}" />  
-    <chmod dir="${src.packages.home}/${gdbm.version}" perm="ugo+wrx" includes="**" />
-    <antcall target="configure-gdbm" />
-    <antcall target="compile-gdbm" /> 
+
+    <if>
+      <bool>
+        <not><available file="${src.packages.home}/${gdbm.version}/.flagfile"/></not>
+      </bool>
+
+      <get src="http://www.greenstone.org/gs3files/${gdbm.version}.tar.gz"
+        dest="${src.packages.home}/${gdbm.version}.tar.gz" usetimestamp="true"/>
+      <untar compression= "gzip" src="${src.packages.home}/${gdbm.version}.tar.gz" dest="${src.packages.home}" />
+      <echo file="${src.packages.home}/${gdbm.version}/.flagfile">
+        the timestamp of this file is the time that gdbm was extracted from the tar files.
+        it is used to figure out whether the files need to be refreshed or not in `ant prepare-gdbm`
+      </echo>
+      <chmod dir="${src.packages.home}/${gdbm.version}" perm="ugo+wrx" includes="**" />
+      <antcall target="configure-gdbm" />
+      <antcall target="compile-gdbm" />
+
+     <else>
+       <echo>GDBM has been prepared, will not prepare</echo>
+       <echo>Delete ${src.packages.home}/${gdbm.version}/.flagfile to force a fresh prepare</echo>
+     </else>
+
+    </if>
+
   </target>  
 
