Index: /main/trunk/release-kits/bin/rk
===================================================================
--- /main/trunk/release-kits/bin/rk	(revision 29392)
+++ /main/trunk/release-kits/bin/rk	(revision 29393)
@@ -46,4 +46,12 @@
 toexec="ant -lib \"`pwd`/installer/classes\" -f \"$RK_HOME/kits/$rk_name/ant-scripts/build.xml\" \"-Dbasedir=`pwd`\" \"-Drk.home=$RK_HOME\" \"-Drk.name=$rk_name\""
 
+# Generally, an ant property can be true|on|yes vs false|off|no (or left unset)
+# see https://ant.apache.org/manual/properties.html#if+unless
+# However, the release-kit code requires envvar KEEP_SRC to be "true" in order to stop it deleting source code
+#KEEP_SRC=true
+if test -n $KEEP_SRC ; then
+    toexec="$toexec \"-Dkeep.src=$KEEP_SRC\""
+fi
+
 #pass on the arguments
 while [ "$1" != "" ]; do
Index: /main/trunk/release-kits/kits/rk2/ant-scripts/compile.xml
===================================================================
--- /main/trunk/release-kits/kits/rk2/ant-scripts/compile.xml	(revision 29392)
+++ /main/trunk/release-kits/kits/rk2/ant-scripts/compile.xml	(revision 29393)
@@ -251,5 +251,8 @@
 
 		<!-- Delete all but the lib folder and the setup.bash script of the gnome support library -->
-		<if><bool><or><equals arg1="${rk.os}" arg2="mac"/><equals arg1="${rk.os}" arg2="linux"/></or></bool>
+		<if><bool><and>
+		  <not><equals arg1="${keep.src}" arg2="true"/></not>
+		  <or><equals arg1="${rk.os}" arg2="mac"/><equals arg1="${rk.os}" arg2="linux"/></or>
+		</and></bool>
 			<delete dir="${basedir}/compiled/ext/gnome-lib-minimal/${os.shell}/bin"/>
 			<delete dir="${basedir}/compiled/ext/gnome-lib-minimal/${os.shell}/include"/>
@@ -308,6 +311,8 @@
 		</if></else></if>
 
-		<delete dir="compiled/gli/jar"/>
-		<delete dir="compiled/gli/classes/org"/>
+		<if><bool><not><equals arg1="${keep.src}" arg2="true"/></not></bool>
+		  <delete dir="compiled/gli/jar"/>
+		  <delete dir="compiled/gli/classes/org"/>
+		</if>
 		<move file="compiled/gli/GLIServer.jar" todir="compiled/bin/java"/>
 
@@ -316,9 +321,11 @@
 
 		<!-- delete the source code -->
-		<delete><fileset dir="compiled" includes="Makefile,config.cache,config.h,config.log,stamp-h,config.status"/></delete>
-		<delete dir="compiled/common-src"/>
-		<delete dir="compiled/build-src"/>
-		<delete dir="compiled/runtime-src"/>
-		<delete><fileset dir="compiled" includes="Install.txt,acconfig.h,aclocal.m4,config.guess,config.sub,configtest.pl,configure,configure.in,install-sh,Makefile.in,micotest.cpp,config.h.in,win32.mak,win32cfg.h,lib/**/*.a"/></delete>
+		<if><bool><not><equals arg1="${keep.src}" arg2="true"/></not></bool>		
+		  <delete><fileset dir="compiled" includes="Makefile,config.cache,config.h,config.log,stamp-h,config.status"/></delete>
+		  <delete dir="compiled/common-src"/>
+		  <delete dir="compiled/build-src"/>
+		  <delete dir="compiled/runtime-src"/>
+		  <delete><fileset dir="compiled" includes="Install.txt,acconfig.h,aclocal.m4,config.guess,config.sub,configtest.pl,configure,configure.in,install-sh,Makefile.in,micotest.cpp,config.h.in,win32.mak,win32cfg.h,lib/**/*.a"/></delete>
+		</if>
 
 		<!-- strip .svn working-copy dirs -->
Index: /main/trunk/release-kits/kits/rk3/ant-scripts/compile.xml
===================================================================
--- /main/trunk/release-kits/kits/rk3/ant-scripts/compile.xml	(revision 29392)
+++ /main/trunk/release-kits/kits/rk3/ant-scripts/compile.xml	(revision 29393)
@@ -88,4 +88,5 @@
 			<propertyset refid="forward.properties"/>
 			<property name="properties.accepted" value="true"/>
+			<property name="properties.keep.src" value="${keep.src}"/>
 		</ant>
 
Index: /main/trunk/release-kits/shared/core/ant-scripts/shared.xml
===================================================================
--- /main/trunk/release-kits/shared/core/ant-scripts/shared.xml	(revision 29392)
+++ /main/trunk/release-kits/shared/core/ant-scripts/shared.xml	(revision 29393)
@@ -236,5 +236,5 @@
 
 	<!-- a target to strip any directory of .svn folders -->
-	<target name="strip-svn-dirs">
+	<target name="strip-svn-dirs" unless="${keep.src}">
 		<delete includeemptydirs="true">
 			<fileset dir="${dir}" defaultexcludes="false">
@@ -380,5 +380,5 @@
 
 	<!-- target to tidy gli up for distribution -->
-	<target name="gli-tidy-for-dist">
+	<target name="gli-tidy-for-dist" unless="${keep.src}">
 		<!-- delete unneeded things -->
 		<delete file="${glibasedir}/.greenstonestore"/>		
