Index: /greenstone3/trunk/build.xml
===================================================================
--- /greenstone3/trunk/build.xml	(revision 14603)
+++ /greenstone3/trunk/build.xml	(revision 14604)
@@ -22,4 +22,5 @@
 	<taskdef name="getuserandpassword" classname="org.greenstone.anttasks.MyGetUserAndPassword" classpath="${basedir}/lib/java/anttasks.jar"/>
 	<taskdef name="svn" classname="org.tigris.subversion.svnant.SvnTask" classpathref="project.classpath"/>
+	<taskdef name="rsr" classname="org.greenstone.anttasks.RegexSearchReplace" classpath="${basedir}/lib/java/anttasks.jar"/>
 
 
@@ -75,5 +76,21 @@
   <property name="app.name"      value="greenstone3"/>
   <property name="app.path"      value="/${app.name}"/>
-  <property name="app.version"   value="3.03"/>
+
+
+  <!-- version number stuff -->
+
+  <!-- app.version defaults to trunk -->
+  <condition property="app.version" value="trunk">
+    <not><isset property="app.version"/></not>
+  </condition>
+
+	<!-- determine the 'branch path' -->
+  <condition property="branch.path" value="trunk">
+    <equals arg1="${app.version}" arg2="trunk" />
+  </condition>
+  <condition property="branch.path" value="branches/${app.version}">
+    <not><equals arg1="${app.version}" arg2="trunk" /></not>
+  </condition>
+
 
   <property name="flax.svn.root" value="http://svn.greenstone.org/flax"/>
@@ -475,6 +492,6 @@
     <filter token="tomcat.server" value="${tomcat.server}"/>
     <filter token="tomcat.port" value="${tomcat.port}"/>
-    <copy file="${basedir}/resources/java/global.properties.in" tofile="${web.classes}/global.properties" filtering="true" overwrite="true"/> 
-    <copy file="${basedir}/resources/java/log4j.properties.in" tofile="${web.classes}/log4j.properties" filtering="true" overwrite="true"/> 
+    <copy file="${basedir}/resources/java/global.properties.in" tofile="${web.classes}/global.properties" filtering="true" overwrite="true"/>
+    <copy file="${basedir}/resources/java/log4j.properties.in" tofile="${web.classes}/log4j.properties" filtering="true" overwrite="true"/>
     <chmod file="${web.classes}/global.properties" perm="600"/>
     <chmod file="${web.classes}/log4j.properties" perm="600"/>
@@ -872,5 +889,5 @@
 <!--  <target name="checkout-indexers" depends="check-svnroot,init" if="independent-indexers" unless="nocvs.mode"> -->
     <svn>
-		<checkout url="${svn.root}/indexers/trunk" dest="${src.packages.home}/indexers"/>
+		<checkout url="${svn.root}/indexers/${branch.path}" dest="${src.packages.home}/indexers"/>
 	</svn>
   </target>
@@ -1042,43 +1059,42 @@
 
   <target name="checkout-gs2build" depends="init" if="collection.building.enabled" unless="nocvs.mode">
-<!--  <target name="checkout-gs2build" depends="check-cvsroot,init" if="collection.building.enabled" unless="nocvs.mode"> -->
     <echo>checking out gs2build</echo>
 		<!-- svn checkouts -->
 		<svn>
 			<!-- perllib -->
-			<checkout url="${svn.root}/gsdl/trunk/perllib" destPath="gs2build/perllib"/>
+			<checkout url="${svn.root}/gsdl/${branch.path}/perllib" destPath="gs2build/perllib"/>
 
 			<!-- selected packages -->
-			<checkout url="${svn.root}/gsdl/trunk/packages/cpan" destPath="gs2build/packages/cpan"/>
-			<checkout url="${svn.root}/gsdl/trunk/packages/expat" destPath="gs2build/packages/expat"/>
-			<checkout url="${svn.root}/gsdl/trunk/packages/html-tidy" destPath="gs2build/packages/html-tidy"/>
-			<checkout url="${svn.root}/gsdl/trunk/packages/isis-gdl" destPath="gs2build/packages/isis-gdl"/>
-			<checkout url="${svn.root}/gsdl/trunk/packages/kea" destPath="gs2build/packages/kea"/>
-			<checkout url="${svn.root}/gsdl/trunk/packages/pdftohtml" destPath="gs2build/packages/pdftohtml"/>
-			<checkout url="${svn.root}/gsdl/trunk/packages/rtftohtml" destPath="gs2build/packages/rtftohtml"/>
-			<checkout url="${svn.root}/gsdl/trunk/packages/w3mir" destPath="gs2build/packages/w3mir"/>
-			<checkout url="${svn.root}/gsdl/trunk/packages/wget" destPath="gs2build/packages/wget"/>
-			<checkout url="${svn.root}/gsdl/trunk/packages/windows" destPath="gs2build/packages/windows"/>
-			<checkout url="${svn.root}/gsdl/trunk/packages/wv" destPath="gs2build/packages/wv"/>
-			<checkout url="${svn.root}/gsdl/trunk/packages/xlhtml" destPath="gs2build/packages/xlhtml"/>
-			<checkout url="${svn.root}/gsdl/trunk/packages/yaz" destPath="gs2build/packages/yaz"/>
+			<checkout url="${svn.root}/gsdl/${branch.path}/packages/cpan" destPath="gs2build/packages/cpan"/>
+			<checkout url="${svn.root}/gsdl/${branch.path}/packages/expat" destPath="gs2build/packages/expat"/>
+			<checkout url="${svn.root}/gsdl/${branch.path}/packages/html-tidy" destPath="gs2build/packages/html-tidy"/>
+			<checkout url="${svn.root}/gsdl/${branch.path}/packages/isis-gdl" destPath="gs2build/packages/isis-gdl"/>
+			<checkout url="${svn.root}/gsdl/${branch.path}/packages/kea" destPath="gs2build/packages/kea"/>
+			<checkout url="${svn.root}/gsdl/${branch.path}/packages/pdftohtml" destPath="gs2build/packages/pdftohtml"/>
+			<checkout url="${svn.root}/gsdl/${branch.path}/packages/rtftohtml" destPath="gs2build/packages/rtftohtml"/>
+			<checkout url="${svn.root}/gsdl/${branch.path}/packages/w3mir" destPath="gs2build/packages/w3mir"/>
+			<checkout url="${svn.root}/gsdl/${branch.path}/packages/wget" destPath="gs2build/packages/wget"/>
+			<checkout url="${svn.root}/gsdl/${branch.path}/packages/windows" destPath="gs2build/packages/windows"/>
+			<checkout url="${svn.root}/gsdl/${branch.path}/packages/wv" destPath="gs2build/packages/wv"/>
+			<checkout url="${svn.root}/gsdl/${branch.path}/packages/xlhtml" destPath="gs2build/packages/xlhtml"/>
+			<checkout url="${svn.root}/gsdl/${branch.path}/packages/yaz" destPath="gs2build/packages/yaz"/>
 			
 			<!-- some of src (db2txt hashfile phind txt2db) -->
-			<checkout url="${svn.root}/gsdl/trunk/src/db2txt" destPath="gs2build/src/db2txt"/>
-			<checkout url="${svn.root}/gsdl/trunk/src/hashfile" destPath="gs2build/src/hashfile"/>
-			<checkout url="${svn.root}/gsdl/trunk/src/phind" destPath="gs2build/src/phind"/>
-			<checkout url="${svn.root}/gsdl/trunk/src/txt2db" destPath="gs2build/src/txt2db"/>
+			<checkout url="${svn.root}/gsdl/${branch.path}/src/db2txt" destPath="gs2build/src/db2txt"/>
+			<checkout url="${svn.root}/gsdl/${branch.path}/src/hashfile" destPath="gs2build/src/hashfile"/>
+			<checkout url="${svn.root}/gsdl/${branch.path}/src/phind" destPath="gs2build/src/phind"/>
+			<checkout url="${svn.root}/gsdl/${branch.path}/src/txt2db" destPath="gs2build/src/txt2db"/>
 
 			<!-- bin -->
-			<checkout url="${svn.root}/gsdl/trunk/bin/script" destPath="gs2build/bin/script"/>
+			<checkout url="${svn.root}/gsdl/${branch.path}/bin/script" destPath="gs2build/bin/script"/>
 
 			<!-- mappings -->
-			<checkout url="${svn.root}/gsdl/trunk/mappings" destPath="gs2build/mappings"/>
+			<checkout url="${svn.root}/gsdl/${branch.path}/mappings" destPath="gs2build/mappings"/>
 
 			<!-- etc/packages -->
-			<checkout url="${svn.root}/gsdl/trunk/etc/packages" destPath="gs2build/etc/packages"/>
+			<checkout url="${svn.root}/gsdl/${branch.path}/etc/packages" destPath="gs2build/etc/packages"/>
 	
 			<!-- collect -->
-			<checkout url="${svn.root}/gsdl/trunk/collect/modelcol" destPath="gs2build/collect/modelcol"/>
+			<checkout url="${svn.root}/gsdl/${branch.path}/collect/modelcol" destPath="gs2build/collect/modelcol"/>
 
 			<!-- gs2build-extra -->
@@ -1086,5 +1102,5 @@
 
 			<!-- indexers -->
-			<checkout url="${svn.root}/indexers/trunk" destPath="gs2build/indexers"/>
+			<checkout url="${svn.root}/indexers/${branch.path}" destPath="gs2build/indexers"/>
 
 
@@ -1094,24 +1110,24 @@
 		<!-- some files from lib -->
 		<mkdir dir="gs2build/lib"/>
-		<get src="${svn.root}/gsdl/trunk/lib/text_t.h" dest="gs2build/lib/text_t.h"/>
-		<get src="${svn.root}/gsdl/trunk/lib/text_t.cpp" dest="gs2build/lib/text_t.cpp"/>
-		<get src="${svn.root}/gsdl/trunk/lib/gsdlconf.h" dest="gs2build/lib/gsdlconf.h"/>
+		<get src="${svn.root}/gsdl/${branch.path}/lib/text_t.h" dest="gs2build/lib/text_t.h"/>
+		<get src="${svn.root}/gsdl/${branch.path}/lib/text_t.cpp" dest="gs2build/lib/text_t.cpp"/>
+		<get src="${svn.root}/gsdl/${branch.path}/lib/gsdlconf.h" dest="gs2build/lib/gsdlconf.h"/>
 
 		<!-- some files from etc -->
-		<get src="${svn.root}/gsdl/trunk/etc/marctodc.txt" dest="gs2build/etc/marctodc.txt"/>
-		<get src="${svn.root}/gsdl/trunk/etc/dc2marc-mapping.xml" dest="gs2build/etc/dc2marc-mapping.xml"/>
-		<get src="${svn.root}/gsdl/trunk/etc/dc2marc.xsl" dest="gs2build/etc/dc2marc.xsl"/>
-		<get src="${svn.root}/gsdl/trunk/etc/qdc2marc-mapping.xml" dest="gs2build/etc/qdc2marc-mapping.xml"/>
+		<get src="${svn.root}/gsdl/${branch.path}/etc/marctodc.txt" dest="gs2build/etc/marctodc.txt"/>
+		<get src="${svn.root}/gsdl/${branch.path}/etc/dc2marc-mapping.xml" dest="gs2build/etc/dc2marc-mapping.xml"/>
+		<get src="${svn.root}/gsdl/${branch.path}/etc/dc2marc.xsl" dest="gs2build/etc/dc2marc.xsl"/>
+		<get src="${svn.root}/gsdl/${branch.path}/etc/qdc2marc-mapping.xml" dest="gs2build/etc/qdc2marc-mapping.xml"/>
 
 		<!-- some files from the gsdl root directory -->
-		<get src="${svn.root}/gsdl/trunk/setup.bash" dest="gs2build/setup.bash"/>
-		<get src="${svn.root}/gsdl/trunk/config.sub" dest="gs2build/config.sub"/>
-		<get src="${svn.root}/gsdl/trunk/config.guess" dest="gs2build/config.guess"/>
-		<get src="${svn.root}/gsdl/trunk/config.h.in" dest="gs2build/config.h.in"/>
-		<get src="${svn.root}/gsdl/trunk/configtest.pl" dest="gs2build/configtest.pl"/>
-		<get src="${svn.root}/gsdl/trunk/install-sh" dest="gs2build/install-sh"/>
-		<get src="${svn.root}/gsdl/trunk/acconfig.h" dest="gs2build/acconfig.h"/>
-		<get src="${svn.root}/gsdl/trunk/aclocal.m4" dest="gs2build/aclocal.m4"/>
-		<get src="${svn.root}/gsdl/trunk/WIN32cfg.h" dest="gs2build/WIN32cfg.h"/>
+		<get src="${svn.root}/gsdl/${branch.path}/setup.bash" dest="gs2build/setup.bash"/>
+		<get src="${svn.root}/gsdl/${branch.path}/config.sub" dest="gs2build/config.sub"/>
+		<get src="${svn.root}/gsdl/${branch.path}/config.guess" dest="gs2build/config.guess"/>
+		<get src="${svn.root}/gsdl/${branch.path}/config.h.in" dest="gs2build/config.h.in"/>
+		<get src="${svn.root}/gsdl/${branch.path}/configtest.pl" dest="gs2build/configtest.pl"/>
+		<get src="${svn.root}/gsdl/${branch.path}/install-sh" dest="gs2build/install-sh"/>
+		<get src="${svn.root}/gsdl/${branch.path}/acconfig.h" dest="gs2build/acconfig.h"/>
+		<get src="${svn.root}/gsdl/${branch.path}/aclocal.m4" dest="gs2build/aclocal.m4"/>
+		<get src="${svn.root}/gsdl/${branch.path}/WIN32cfg.h" dest="gs2build/WIN32cfg.h"/>
 
 	</target>
@@ -1227,5 +1243,5 @@
     <echo>checking out gli</echo>
     <svn>
-		<checkout url="${svn.root}/gli/trunk" destPath="gli"/>
+		<checkout url="${svn.root}/gli/${branch.path}" destPath="gli"/>
 	</svn>
   </target>
@@ -1291,13 +1307,14 @@
     <!-- gli -->
     <property name="gli.home" value="${basedir}/gli"/>
+
+		<!-- change the version number -->
+		<rsr file="${gli.home}/src/org/greenstone/gatherer/Gatherer.java" pattern="^(.*)String\s*PROGRAM_VERSION\s*=\s*&quot;(.*)&quot;" replacement="$1String PROGRAM_VERSION = &quot;${app.version}&quot;"/>
     <!-- linux -->
-    <exec executable="makegli.sh" os="${os.unix}" dir="${gli.home}"
-      resolveExecutable="true"/>
+    <exec executable="makegli.sh" os="${os.unix}" dir="${gli.home}" resolveExecutable="true"/>
      <!--remote gli-->
      <exec executable="makejar.sh" os="${os.unix}" dir="${gli.home}"
       resolveExecutable="true"/>
     <!-- windows -->
-    <exec executable="makegli.bat" os="${os.windows}" dir="${gli.home}"
-      resolveExecutable="true"/>
+    <exec executable="makegli.bat" os="${os.windows}" dir="${gli.home}" resolveExecutable="true"/>
     <!--remote gli-->
      <exec executable="makejar.bat" os="${os.windows}" dir="${gli.home}"
Index: /greenstone3/trunk/src/java/org/greenstone/anttasks/RegexSearchReplace.java
===================================================================
--- /greenstone3/trunk/src/java/org/greenstone/anttasks/RegexSearchReplace.java	(revision 14604)
+++ /greenstone3/trunk/src/java/org/greenstone/anttasks/RegexSearchReplace.java	(revision 14604)
@@ -0,0 +1,117 @@
+package org.greenstone.anttasks;
+
+import org.apache.tools.ant.*;
+import org.apache.tools.ant.taskdefs.*;
+import java.util.*;
+import java.io.*;
+import java.util.regex.*;
+
+
+public class RegexSearchReplace extends Task {
+	private File file = null;
+	private String pattern = null;
+	private String replacement = null;
+	
+
+	/**
+	 * for testing
+	 */
+	public static void main( String[] args ) {
+		RegexSearchReplace rsr = new RegexSearchReplace();
+		rsr.setFile(new File (args[0]));
+		rsr.setPattern(args[1]);
+		rsr.setReplacement(args[2]);
+
+		rsr.execute();
+
+	}
+
+	public void execute() {
+
+		if ( file == null ) {
+			throw new BuildException( "Error - No file specified !!" );
+		}
+
+		if ( pattern == null ) {
+			throw new BuildException( "Error - No pattern specified !!" );
+		}
+
+		if (replacement == null) {
+			replacement = "";
+		}
+
+
+		//create the output stream
+		BufferedWriter out = null;
+		File temp = null;
+		try {
+			// Create temp file.
+			temp = File.createTempFile("rsr", ".tmp");
+
+			// Delete temp file when program exits.
+			temp.deleteOnExit();
+
+			// Write to temp file
+			out = new BufferedWriter(new FileWriter(temp));
+
+		} catch (IOException e) {}
+
+
+		//create the input stream
+		BufferedReader in = null;
+		try {
+			in = new BufferedReader(new FileReader( file ));
+		} catch ( Exception e ) {}
+
+		//pass the file through, searching and replacing
+		String line;
+		try {
+			while ( (line = in.readLine()) != null ) {
+				line = line.replaceAll( pattern, replacement);
+				out.write(line);
+				out.newLine();
+			}
+			//close them both up
+			in.close();
+			out.close();
+
+		} catch ( Exception e ) {
+			e.printStackTrace();
+		}
+
+
+
+		//copy the new file (temp) over the original
+		try {
+			InputStream i = new FileInputStream(temp);
+			OutputStream o = new FileOutputStream(file);
+
+			// Transfer bytes from in to out
+			byte[] buf = new byte[1024];
+			int len;
+			while ((len = i.read(buf)) > 0) {
+			   o.write(buf, 0, len);
+			}
+
+			//close them up
+			i.close();
+			o.close();
+		} catch ( Exception e ) {}
+		
+	}
+
+   
+	public void setFile(File file) {
+			this.file = file;
+	}
+
+	public void setPattern(String pattern) {
+			this.pattern = pattern;
+	}
+
+	public void setReplacement(String replacement) {
+			this.replacement = replacement;
+	}
+
+
+}
