<!-- default ANT buildscript
	 author: dennis@brains2b.nl
	 date:   04/17/2004
	 ver:	 0.30
	 	 
	 use:
	 only fill projectname and ver and add possible dependencies to create a new
	 package. It will automatically copy license.txt from
	 /doc to the jar.
	 
-->
<project name="ResX" default="dist" basedir=".">

  <!-- set global properties for this build -->
  <property name="ver" value="0.15"/>
  <property name="src" value="src" />
  <property name="build" value="bld" />
  <property name="dist" value="dist" />
  <property name="shared.dist" value="../dist" />
  <property name="java.doc"  value="doc/javadoc" />
  <property name="ext.lib" value="/usr/java/lib" />
  
  <target name="prepare">
    <condition property="ext.lib" value="D:/java/ext">
    	<os family="windows"/>
    </condition>
    	
    <!-- Create the time stamp -->
    <tstamp/>
    <!-- Create the build directory structure used by compile -->
    <mkdir dir="${build}" />
    <mkdir dir="${dist}" />
    <copy todir="${build}">
    	<fileset dir="doc" includes="license.txt"/>
    </copy>
  </target>

  
  <target name="dependency" depends="clean,prepare">
    <!-- Put your class-files or jars you need to include
         in your package directly into the ${dist} directory -->
    <copy todir="${dist}">
    	<fileset dir="${shared.dist}" includes="twelbox.jar"/>
    </copy>
    <copy todir="${dist}">
    	<fileset dir="${shared.dist}" includes="Squeler.jar"/>
    </copy>
  </target>  
 

  <target name="compile" depends="dependency">
    <!-- Compile the java code from ${src} into ${build} -->
    <javac destdir="${build}">
    	<src path="${src}"/> 
    	<exclude name="test/**"/>
    	<classpath>
    		<fileset dir="${ext.lib}">
    			<include name="*.jar" />
    		</fileset>
    		<fileset dir="${shared.dist}">
    			<include name="*.jar" />
    		</fileset>
    	</classpath>
    </javac>
  </target>

  <target name="dist" depends="compile">
  	<!-- Put everything in ${build} into the [projectname]-${ver}-${DSTAMP}.jar file -->
    <jar jarfile="${dist}/${ant.project.name}-${ver}.jar" 
    	manifest="META-INF/Manifest.mf"
    	basedir="${build}" />
    <copy tofile="${shared.dist}/${ant.project.name}.jar" 
    	file="${dist}/${ant.project.name}-${ver}.jar" />
  </target>

  <target name="junit" depends="dist">
	<javac destdir="${build}">
    	<src path="${src}"/> 
    	<include name="test/**"/>
    	<classpath>
    		<fileset dir="${ext.lib}">
    			<include name="*.jar" />
    		</fileset>
    		<fileset dir="${shared.dist}">
    			<include name="*.jar" />
    		</fileset>
    	</classpath>
    </javac>
  	<junit printsummary="no" haltonfailure="no">
  	  <classpath>
  	  	<pathelement location="${build}"/>
  	  	<fileset dir="${shared.dist}">
    			<include name="*.jar" />
    	</fileset>
    	<fileset dir="${ext.lib}">
    			<include name="*.jar" />
    	</fileset>
  	  </classpath>
  	  <formatter type="brief" usefile="false" />
  	  <batchtest fork="no">
      	<fileset dir="${src}">
      		<include name="test/**/*Test.java" />
    	</fileset>
  	</batchtest>
	</junit>
  </target>  

  <target name="javadoc">
  	<mkdir dir="${java.doc}"/>
  	<javadoc packagenames="org.brains2b.*" 
  		sourcepath="${src}" 
  		stylesheetfile="../layout/project/javadoc.css"
  		destdir="${java.doc}"
  	>
  	<classpath>
    		<fileset dir="${shared.dist}">
    			<include name="*.jar" />
    		</fileset>
    	</classpath>
    </javadoc>
  </target>

  <target name="clean">
    <!-- Delete the ${build} directory trees -->
    <delete dir="${build}" />
  </target>


  <target name="package" depends="dist">
  <!-- build the zip and tar packages for online use -->
  	<copy tofile="${dist}/${ant.project.name}.jar"
  		file="${dist}/${ant.project.name}-${ver}.jar" />
  	<zip zipfile="${dist}/${ant.project.name}-${ver}.zip">
  		<fileset dir="${basedir}" includes="src/**,doc/**" excludes="doc/ext/**"/>
  		<fileset dir="${dist}" includes="${ant.project.name}.jar"/>
  		<fileset dir="${dist}" includes="twelbox.jar"/>
  		<fileset dir="${dist}" includes="Squeler.jar"/>
  		<fileset dir="${basedir}" includes="build.xml"/>
  	</zip>
  	<tar tarfile="${dist}/${ant.project.name}-${ver}.tar">
       <tarfileset dir="${basedir}" includes="${src}/**,doc/**" excludes="doc/ext/**" />
   	   <tarfileset mode="755" dir="${dist}" includes="${ant.project.name}.jar"/>
   	   <tarfileset dir="${dist}" includes="twelbox.jar"/>
  	   <tarfileset dir="${dist}" includes="Squeler.jar"/>
   	   <tarfileset dir="${basedir}" includes="build.xml"/>
  	</tar>
  	<gzip zipfile="${dist}/${ant.project.name}-${ver}.tar.gz" src="${dist}/${ant.project.name}-${ver}.tar"/>
  	<delete file="${dist}/${ant.project.name}-${ver}.tar" />
  	<delete file="${dist}/${ant.project.name}.jar" />
  </target>
</project>
  