Index: gs3-extensions/testing/trunk/src/build.xml
===================================================================
--- gs3-extensions/testing/trunk/src/build.xml	(revision 32679)
+++ gs3-extensions/testing/trunk/src/build.xml	(revision 32680)
@@ -1,22 +1,116 @@
 <?xml version="1.0"?>
 <project name="Greenstone3 Testing Extension" default="build-util-jar" basedir=".">
-	<target name="build-util-jar">
-		<mkdir dir="${basedir}/build"/>
-		<javac srcdir="${basedir}/src" destdir="${basedir}/build">
-			<classpath>
-				<fileset dir="${basedir}/lib/java">
-					<include name="*.jar"/>
-				</fileset>
-			</classpath>
-			<include name="org/greenstone/gsdl3/testing/*.java"/>
-		</javac>
-		<jar destfile="${basedir}/lib/java/GSTestingUtil.jar">
-			<fileset dir="${basedir}/build">
-				<include name="org/greenstone/gsdl3/testing/**"/>
-			</fileset>
-			<manifest>
-				<attribute name="Built-By" value="Greenstone" />
-			</manifest>
-		</jar>
-	</target>
+  <!-- get properties from the environment -->
+  <property environment="env"/>
+  <property name="compile.includeantruntime" value="false"/> <!-- to get rid of annoying 'ant' warning -->
+
+  <property name="gli.home" value="${env.GSDL3SRCHOME}/gli"/>
+  
+  <target name="build-util-jar">
+    <mkdir dir="${basedir}/build"/>
+    <javac srcdir="${basedir}/src" destdir="${basedir}/build">
+      <classpath>
+	<fileset dir="${basedir}/lib/java">
+	  <include name="*.jar"/>
+	</fileset>
+      </classpath>
+      <include name="org/greenstone/gsdl3/testing/*.java"/>			
+    </javac>
+    <jar destfile="${basedir}/lib/java/GSTestingUtil.jar">
+      <fileset dir="${basedir}/build">
+	<include name="org/greenstone/gsdl3/testing/**"/>			  
+      </fileset>
+      <manifest>
+	<attribute name="Built-By" value="Greenstone" />
+      </manifest>
+    </jar>
+  </target>
+  
+<!-- +++++++++++++ TUTORIAL TESTING TARGETS ++++++++++++++ -->
+<target name="needs-make-gli-jar">  
+  <condition property="gli-jar-missing">
+    <not>
+      <available file="${gli.home}/GLI.jar"/>
+    </not>
+    </condition>
+    
+    <fail if="gli-jar-missing" message="Run the makegli followed by makejar scripts in the gli folder before starting the Greenstone server."/>
+</target>
+
+<target name="needs-gs3-setup">
+    <!-- has the gs3-setup script been run?? -->
+    <condition property="gs3-setup-not-done">
+      <not>
+	<isset property="env.GSDL3HOME"/>
+      </not>
+    </condition>
+
+    <fail if="gs3-setup-not-done" message="Please run 'gs3-setup' (Windows) or 'source gs3-setup.sh' (Linux/Mac) before starting the Greenstone server."/>
+
+    <echo>GLI HOME: ${gli.home}</echo>
+  </target>
+
+<target name="compile-tutorials-tests" depends="needs-gs3-setup, needs-make-gli-jar">
+
+  <mkdir dir="${basedir}/build"/>
+  <javac
+      srcdir="${basedir}/src"
+      destdir="${basedir}/build"
+      includeantruntime="${compile.includeantruntime}">
+    <classpath>
+      <fileset dir="${basedir}/lib/java">
+	<include name="*.jar"/>
+      </fileset>
+      <fileset dir="${gli.home}">
+	<include name="GLI.jar"/>
+      </fileset>
+    </classpath>			
+    <include name="gstests/tutorials/*.java"/>
+  </javac>
+  <jar destfile="${basedir}/tutorial-tests.jar">
+    <fileset dir="${basedir}/build">
+      <include name="gstests/tutorials/**"/>
+    </fileset>
+    <manifest>
+      <attribute name="Built-By" value="greenstone" />
+    </manifest>
+  </jar>
+</target>
+
+<!-- https://stackoverflow.com/questions/10704324/how-to-add-to-classpath-all-classes-from-set-of-directories-in-ant -->
+<path id="tutorials.path">  
+  <fileset dir="${basedir}/lib/java">
+    <include name="*.jar"/>
+  </fileset>
+  <!--<fileset dir="${basedir}/build">	    
+    <include name="gstests/tutorials/**/*.class"/>
+  </fileset>-->
+  <files includes="${basedir}/tutorial-tests.jar"/>
+
+  <!-- To run GLI, need GLI.jar and its help jars and folder: classes folder, apache.jar, jna.jar, jna-platform.jar, qfslib.jar, rsyntaxtextarea.jar -->
+  <fileset dir="${gli.home}">
+    <include name="GLI.jar"/>
+  </fileset>
+  <pathelement path="${gli.home}/classes"/>
+  <fileset dir="${gli.home}/lib">
+    <include name="*.jar"/>
+  </fileset>  
+</path>
+
+<!-- TODO: for darwin, need to set custom_vm_args, see gli.sh
+TODO: Launching GLI for GS2 is also different -->
+
+<!-- http://ant.1045680.n5.nabble.com/How-to-increase-memory-used-by-JVM-in-Ant-td1355370.html -->
+<target name="run-tutorials-tests" depends="needs-gs3-setup, needs-make-gli-jar">
+  <echo>Tutorial tests</echo>
+  <echo>GSDLHOME: ${env.GSDLHOME}</echo>  
+  <java classname="org.junit.runner.JUnitCore" dir="${gli.home}" fork="true" maxmemory="256m" classpathref="tutorials.path">
+    <arg value="gstests.tutorials.RunGLITest"/>
+    
+  </java>
+  
+  
+</target>
+
 </project>
+
