<project name="seasar" default="dist" basedir=".">

	<property file="project.properties" />

	<fileset id="classpath" dir="${lib}">
		<include name="*" />
		<exclude name="s2*" />
	</fileset>

	<target name="compile">
		<javac srcdir="${src}" destdir="${build}" debug="on">
			<classpath>
				<fileset refid="classpath" />
			</classpath>
		</javac>
	</target>

	<target name="copy" depends="compile">
		<copy todir="${build}">
			<fileset dir="${src}">
				<include name="**/*.properties" />
				<include name="**/*.xml" />
				<include name="**/*.dtd" />
				<exclude name="build.xml" />
			</fileset>
		</copy>
	</target>

	<target name="dist" depends="compile,copy,cleans2jarfile">
		<jar jarfile="${lib}/${frameworkjarfile}" basedir="${build}" includes="${frameworkpackage}, SSR*.properties, s2*.properties" />
		<jar jarfile="${lib}/${extensionjarfile}" basedir="${build}" includes="${extensionpackage}" />
	</target>
	
	<target name="hsqldbstart">
	     <echo message="HSQLDB START" />
	     <java dir="./data" fork="yes"
	             classname="org.hsqldb.Server">
	         <classpath>
	             <fileset refid="classpath" />
	         </classpath>
	     </java>
	 </target>
	 
	 <target name="hsqldbstop">
	     <echo message="HSQLDB STOP" />
	     <java dir="./data" fork="yes"
	             classname="org.hsqldb.util.ShutdownServer">
	         <classpath>
	             <fileset refid="classpath" />
	         </classpath>
	     </java>
	 </target>
	
	<target name="testcopy" depends="copy">
	     <copy todir="${build}">
	         <fileset dir="${src}">
	             <include name="**/*.dicon" />
	             <include name="**/*.txt" />
	             <include name="**/*.xls" />
	         </fileset>
	     </copy>
	 </target>
	 
	 <target name="runtests" depends="testcopy">
	     <parallel>
	         <ant target="hsqldbstart" />
	         <sequential>
	             <sleep seconds="5" />
	             <java fork="yes"
	                     classname="junit.textui.TestRunner">
	                 <classpath>
	                     <fileset refid="classpath" />
	                     <pathelement path="${build}" />
	                 </classpath>
	                 <arg value="test.org.seasar.SeasarAllTests" />
	             </java>
	             <ant target="hsqldbstop" />
	         </sequential>
	     </parallel>
	 </target>

	<target name="cleanbuild">
		<delete dir="${lib}/${frameworkpackage}" />
		<delete dir="${lib}/${extensionpackage}" />
	</target>

	<target name="clean" depends="cleanbuild">
		<delete file="${lib}/${frameworkjarfile}" />
		<delete file="${lib}/${extensionjarfile}" />
	</target>

	<target name="cleans2jarfile">
		<delete>
			<fileset dir="${lib}" defaultexcludes="no">
				<include name="s2*.jar" />
			</fileset>
		</delete>
	</target>

	<target name="setup" depends="dist">
		<mkdir dir="${setupdir}" />
		<delete>
			<fileset dir="${setupdir}" />
		</delete>
		<copy todir="${setupdir}">
			<fileset dir=".">
				<exclude name="**/CVS/**" />
				<exclude name="${build}/**" />
				<exclude name="${lib}/classes12.zip" />
			</fileset>
		</copy>
		<delete dir="${setupdir}build"/>
		<mkdir dir="${setupdir}build"/>
		<zip zipfile="${releasejarfile}" basedir="../setup2" includes="seasar2/"/>
	</target>

</project>
