<?xml version="1.0" encoding="UTF-8"?>
<project
      xmlns:j="jelly:core"
      xmlns:license="license"
      xmlns:util="jelly:util"
      xmlns:ant="jelly:ant"
      xmlns:artifact="artifact"
      xmlns:maven="jelly:maven"
      xmlns:gump="jelly:gump"
      default="sakai:build">
	<goal name="pack-demo"  description="package the sakai demo">

		<attainGoal name="sakai:clean" />
		<attainGoal name="sakai:build" />

		<!-- clear the deploy area -->
		<delete dir="${basedir}/target/demo/"/>
		
		<!-- expand the tomcat 5.5.9 zip from the repo into the target -->
		<ant:unzip src="${maven.repo.local}/tomcat/zips/jakarta-tomcat-5.5.9.zip"
					dest="${basedir}/target/demo/"
					overwrite="true" />

		<!-- expand the tomcat 5.5.9 compat into the target -->
		<ant:unzip src="${maven.repo.local}/tomcat/zips/jakarta-tomcat-compat-5.5.9.zip"
					dest="${basedir}/target/demo/"
					overwrite="true" />

		<!-- deploy sakai to this area -->
		<j:set var="maven.tomcat.home" value="${basedir}/target/demo/jakarta-tomcat-5.5.9/" />
		<attainGoal name="sakai:deploy" />

		<!-- add in demo stuff -->
		<copy file="${basedir}/demo/sakai.properties" tofile="${basedir}/target/demo/jakarta-tomcat-5.5.9/sakai/sakai.properties" />
		<copy file="${basedir}/demo/toolOrder.xml" tofile="${basedir}/target/demo/jakarta-tomcat-5.5.9/sakai/toolOrder.xml" />
		<copy file="${basedir}/demo/readme.txt" tofile="${basedir}/target/demo/jakarta-tomcat-5.5.9/sakai_readme.txt" />
		<copy file="${basedir}/demo/readme_java.txt" tofile="${basedir}/target/demo/jakarta-tomcat-5.5.9/java_readme.txt" />
		<copy todir="${basedir}/target/demo/jakarta-tomcat-5.5.9/licenses/">
			<fileset dir="${basedir}/licenses">
				<exclude name="CVS/**"/>
			</fileset>
		</copy>

		<!-- zip it -->
		<delete file="sakai-demo.zip" />
		<zip destfile="sakai-demo.zip" compress="yes" >
			<zipfileset dir="${maven.tomcat.home}" prefix="sakai-demo" />
		</zip>
		<ant:echo>* * * sakai-demo.zip</ant:echo>

		<!-- tar it -->
		<delete file="sakai-demo.tar" />
		<delete file="sakai-demo.tar.gz" />
		<tar destfile="sakai-demo.tar" longfile="gnu" >
			<tarfileset dir="${maven.tomcat.home}" mode="755" prefix="sakai-demo">
				<include name="bin/*.sh"/>
			</tarfileset>
			<tarfileset dir="${maven.tomcat.home}" prefix="sakai-demo">
				<exclude name="bin/*.sh"/>
			</tarfileset>
		</tar>
		<gzip zipfile="sakai-demo.tar.gz" src="sakai-demo.tar"/>
		<delete file="sakai-demo.tar" />
		<ant:echo>* * * sakai-demo.tar.gz</ant:echo>

		<delete dir="${basedir}/target/demo"/>
	</goal>

	<goal name="pack-src"  description="package the sakai source">

		<zip destfile="sakai-src.zip" compress="yes" >
			<zipfileset dir="." prefix="sakai-src" excludes="CVS/**,**/target/**,**/bin/**,sakai*.zip,sakai*.tar.gz" />
		</zip>
		<ant:echo>* * * sakai-src.zip</ant:echo>

	</goal>

	<goal name="deploy-war">
	  <ant:echo>Copying ${sakaiRwiki.deploy.local} to ${sakaiRwiki.deploy.upload}</ant:echo>
	    <ant:exec executable="/usr/bin/scp" failonerror="true"> 
	      <arg file="${sakaiRwiki.deploy.local}"/>
		<arg value="${sakaiRwiki.deploy.uploadhost}:${sakaiRwiki.deploy.upload}"/>
	    </ant:exec>
	    <ant:echo>SCP copy compressed file: successful.</ant:echo>
	</goal>


</project>
