Index: 3-extensions/mat/trunk/build.properties
===================================================================
--- /gs3-extensions/mat/trunk/build.properties	(revision 22207)
+++ 	(revision )
@@ -1,4 +1,0 @@
-Mat.User_Name =
-Mat.Password =
-Mat.Tomcat_Port =
-Mat.JVM_Version=
Index: /gs3-extensions/mat/trunk/build.xml
===================================================================
--- /gs3-extensions/mat/trunk/build.xml	(revision 22207)
+++ /gs3-extensions/mat/trunk/build.xml	(revision 22208)
@@ -3,5 +3,5 @@
   <property name="gsdl3srchome" value="${env.GSDL3SRCHOME}"/>
 
-  <property name="mat.web" value="web"/>
+  <property name="mat.web" value="${gsdl3srchome}/web/mat"/>
   <property name="mat.bin.scripts" value="bin/script"/>
   <property name="mat.web.scripts" value="${mat.web}/script"/>
@@ -17,7 +17,4 @@
   <property name="mat.tomcat.resources" value="${mat.resources}/tomcat"/>
   <property name="mat.script.resources" value="${mat.resources}/script"/>
-  <property name="mat.webinf" value="${mat.web}/WEB-INF"/>
-  <property name="mat.webinf.lib" value="${mat.webinf}/lib"/>
-  <property name="mat.webinf.classes" value="${mat.webinf}/classes"/>
 
   <property name="gs.jni" value="${gsdl3srchome}/lib/jni"/>	
@@ -28,8 +25,10 @@
   <property name="tomcat" value="${gsdl3srchome}/packages/tomcat"/>
   <property name="tomcat.lib" value="${tomcat}/lib"/>
-  <property name="tomcat.localhost" value="${tomcat}/conf/Catalina/localhost"/>
   
   <path id="classpath">
     <fileset dir="${mat.lib}">
+      <include name="**/*.jar"/>
+    </fileset>
+    <fileset dir="${gsdl3srchome}/lib/java">
       <include name="**/*.jar"/>
     </fileset>
@@ -38,4 +37,7 @@
     </dirset>
   </path>
+
+  <taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask"  classpathref="classpath"/>
+  <taskdef name="if" classname="ise.antelope.tasks.IfTask" classpathref="classpath"/>
   
   <target name ="create_log_folder">
@@ -45,30 +47,22 @@
   <target name="clean">
     <delete file="guiext.jar"/>
-    <delete file="${tomcat.localhost}/mat.xml"/>
     <delete dir="${mat.build}"/>
-    <delete dir="${mat.lib}"/>
-    <delete dir="${mat.web.scripts}"/>
-    <delete dir="${mat.webinf.lib}"/>
-    <delete dir="${mat.webinf.classes}"/>
-  </target>
-  
-  <target name="compile" depends="setup-java-lib,setup-tmp,create_log_folder,move-mat-xml">
+    
+    <xmltask source="${gs.webinf}/web.xml" dest="${gs.webinf}/web.xml">
+      <remove path="/web-app/servlet[servlet-name='mat']"/>
+      <remove path="/web-app/servlet-mapping[servlet-name='mat']"/>
+    </xmltask>
+  </target>
+  
+  <target name="install" depends="setup-tmp,create_log_folder,add-servlet-details">
     <mkdir dir="${mat.classes}"/>
     <javac srcdir="${mat.src}" destdir="${mat.classes}" classpathref="classpath"/>
-    
-    <mkdir dir="${mat.webinf.classes}"/>
-    <copy file="${gs.webinf.classes}/global.properties" tofile="${mat.webinf.classes}/global.properties"/>
-
-    <mkdir dir="${mat.web.scripts}"/>
-    <copy todir="${mat.web.scripts}">
-      <fileset dir="${mat.bin.scripts}"/>
-    </copy>
-
-    <mkdir dir="${mat.webinf.lib}"/>
-    <jar destfile="${mat.webinf.lib}/mat.jar">
+
+    <jar destfile="${mat.lib}/mat.jar">
       <fileset dir="${mat.classes}">
 	<include name="${mat.main.classes}/**"/>
       </fileset>
     </jar>
+    <copy file="${mat.lib}/mat.jar" todir="${gs.webinf.lib}"/>
 
     <jar destfile="guiext.jar">
@@ -77,64 +71,131 @@
       </fileset>
     </jar>
-  </target>
-  
-  <target name="move-mat-xml">
-    <copy file="${mat.tomcat.resources}/mat.xml" tofile="${tomcat.localhost}/mat.xml" overwrite="true">
-      <filterset>
-        <filter token="matwebhome" value="${basedir}/web"/>
-      </filterset>
-    </copy>
-  </target>
-  
-  <target name="setup-java-lib">
-
-    <mkdir dir="${mat.lib}"/>
-    <copy todir="${mat.lib}">
-      <fileset dir="${gs.webinf.lib}">
-      	<include name="**/*.jar"/>
-      </fileset>
-    </copy>
-    
-    <mkdir dir="${mat.lib}"/>
-    <copy todir="${mat.lib}">
-      <fileset dir="${gs.webinf.classes}"/>
-    </copy>
-    
-    <copy todir="${mat.lib}">
-      <fileset dir="${gs.jni}">
-      	<include name="**/*.jar"/>
-      </fileset>
-    </copy>	
-    
-    <copy todir="${mat.lib}">
-      <fileset dir="${tomcat.lib}">
-      	<include name="**/servlet-api.jar"/>
-      </fileset>
-    </copy>
-    
-    <copy todir="${mat.lib}">
-      <fileset dir="./">
-      	<include name="jcommon.jar"/>
-	<include name="jfreechart.jar"/>
-      </fileset>
-    </copy>
-
-    <mkdir dir="${mat.webinf.lib}"/>
-    <copy todir="${mat.webinf.lib}">
-      <fileset dir="${mat.lib}">
-      	<include name="**"/>
-      </fileset>
-    </copy>
-    
+
     <mkdir dir="${mat.web.scripts}"/>
     <copy todir="${mat.web.scripts}">
       <fileset dir="${mat.script.resources}"/>
     </copy>	
-  </target>
-  
+    <copy todir="${mat.web.scripts}">
+      <fileset dir="${mat.bin.scripts}"/>
+    </copy>
+  </target>
+
+  <target name="compress-extension">
+    <if>
+      <bool>
+	<not><available file="7z.jar"/></not>
+      </bool>
+
+      <exec executable="svn">
+	<arg value="export"/>
+	<arg value="http://svn.greenstone.org/main/trunk/release-kits/shared/core/ant-tasks/7z-ant/7z.jar"/>
+      </exec>
+
+    </if>
+    <taskdef name="sevenzip" classname="org.apache.tools.ant.SevenZip" classpath="7z.jar"/>
+ 
+    <if>
+      <bool><equals arg1="${os.name}" arg2="Linux"/></bool>
+      <property name="os" value="linux"/>
+      
+      <else>
+	
+	<if>
+	  <bool><equals arg1="${os.name}" arg2="Mac OS X"/></bool>
+	  <property name="os" value="mac"/>
+	  
+	  <else>
+	  
+	    <if>
+	      <bool><or>
+		  <equals arg1="${os.name}" arg2="Windows 95"/>
+		  <equals arg1="${os.name}" arg2="Windows 98"/>
+		  <equals arg1="${os.name}" arg2="Windows 2000"/>
+		  <equals arg1="${os.name}" arg2="Windows XP"/>
+		  <equals arg1="${os.name}" arg2="Windows NT"/>
+		  <equals arg1="${os.name}" arg2="Windows ME"/>
+		  <equals arg1="${os.name}" arg2="Windows Vista"/>
+		  <equals arg1="${os.name}" arg2="Windows 7"/>
+		</or></bool>
+	      <property name="os" value="windows"/>
+	    </if>
+
+	  </else>
+	</if>
+      </else>
+    </if>
+   
+    <zip destfile="mat.comp" compress="false">
+      <zipfileset dir="${basedir}">
+	<include name="bin"/>
+	<include name="bin/**/*"/>
+	<include name="build"/>
+	<include name="build/**/*"/>
+	<include name="FAQ.txt"/>
+	<include name="guiext.jar"/>
+	<include name="Mat.bat"/>
+	<include name="Mat.sh"/>
+	<include name="properties.xml"/>
+	<include name="README.txt"/>
+	<include name="resources"/>
+	<include name="resources/**/*"/>
+      </zipfileset>
+    </zip>
+    
+    <if>
+      <bool>
+	<equals arg1="${os}" arg2="Windows"/>
+      </bool>
+      
+      <exec executable="${gsdl3srchome}/winutil/7zip.exe">
+	<arg line="a -t7z -mx=9 mat.lzma mat.comp"/>
+      </exec>
+
+      <else>
+	<sevenzip task="encode" input="mat.comp" output="mat.lzma" dictionnary="26"/>
+      </else>
+    </if>
+  </target>
+
+  <target name="add-servlet-details">
+    <xmltask source="${gs.webinf}/web.xml">
+      <copy path="/web-app/servlet[servlet-name='mat']/servlet-name/text()" property="mat.exists"/>
+    </xmltask>
+
+    <if>
+      <bool>
+	<not><equals arg1="${mat.exists}" arg2="mat"/></not>
+      </bool>
+      <xmltask source="${gs.webinf}/web.xml" dest="${gs.webinf}/web.xml">
+	<insert path="/web-app/servlet[last()]" position="after">
+  <![CDATA[
+  <servlet>
+    <servlet-name>mat</servlet-name>
+    <description>Metadata Analysis Tool</description>
+    <servlet-class>org.greenstone.mat.servlet.MatServlet</servlet-class>
+  </servlet>
+  ]]>
+	</insert>
+	<insert path="/web-app/servlet-mapping[last()]" position="after">
+  <![CDATA[
+  <servlet-mapping>
+    <servlet-name>mat</servlet-name>
+    <url-pattern>/mat</url-pattern>
+  </servlet-mapping>
+  ]]>
+	</insert>
+      </xmltask>
+
+      <else>
+	<echo>MAT servlet definition already exists in the Greenstone web.xml</echo>
+      </else>
+    </if>
+  </target>
+
   <target name ="clean-tmp">
     <delete dir="${mat.tmp}"/>
     <echo> ${mat.tmp} has been removed </echo>
   </target>
+
   <target name ="setup-tmp">
     <mkdir dir="./tmp"/>
@@ -142,5 +203,5 @@
     <echo file="${mat.tmp}/log.txt">This is the log file.</echo>
   </target>
-  <target name="clean-compile" depends="clean,compile"/>
+  <target name="clean-compile" depends="clean,install"/>
   
 </project>
