<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   Filename: $RCSfile$
   Purpose:  Ant build file for EvA2.

             Ant-Download: http://jakarta.apache.org/ant
             Ant-Manual:   http://jakarta.apache.org/ant/manual/index.html

   Precondition: 1. Ant should be installed.
                 2. JAVA_HOME environment variable contains the path to JDK1.5 or higher
                 3. ANT_HOME environment variable contains the path to ant's home directory

   Language: XML
   Compiler: Ant
   Authors:  M.Kronfeld, H.Planatscher, Holger Ulmer, Felix Streichert, Joerg Wegner
   Version:  $Revision: 284 $
             $Date: 2007-11-27 14:37:05 +0100 (Tue, 27 Nov 2007) $
             $Author: mkron $
   Copyright (c) Dept. Computer Architecture, University of Tuebingen, Germany
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->

<project name="EvA2" default="compile" basedir="..">

<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        Set properties
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->

  <!-- SET THE DIRECTORY PROPERTIES -->
	<property name="source.directory"				value="src" />
	<property name="ant.directory"					value="ant" />
	<property name="build.directory"				value="build" />
	<property name="resources.directory"			value="resources" />
	<property name="library.directory"				value="lib" />
	<property name="matlabinterface.basedir"		value="resources/MatlabInterface" />
	<property name="matlabinterface.title"			value="JEInterface" />
	<property name="distribution.directory"			value="dist" />
	<property name="source.distribution.directory"	value="${distribution.directory}/src-dist" />
	<property name="binary.distribution.directory"	value="${distribution.directory}/bin-dist" />
	<property name="javadoc.directory"				value="doc/api" />
	<property name="jar.name"						value="EvA2Base" />
	<property name="srcpack.name"					value="EvA2BaseSrc" />
	<!-- SET THESE PATHES IF YOU WANT TO COMPILE ADDITIONAL EvA2 PACKAGES -->
	<property name="JE2Probs.directory"				value="../JE2Probs" />	
	<property name="JE2ESModel.directory"			value="../JE2ESModel" />			
	<property name="JE2Research.directory"			value="../JE2Research" />
	
	<condition property="JE2Probs.available" else="false">
		<available file="${JE2Probs.directory}"/>
	</condition>
	<condition property="JE2ESModel.available" else="false">
		<available file="${JE2ESModel.directory}"/>
	</condition>
	<condition property="JE2Research.available" else="false">
		<available file="${JE2Research.directory}"/>
	</condition>

	<!-- SET THE JAVA BINARY LIBRARIES PROPERTIES -->
	<property name="ant.java.version"							 value="1.5" />

	<!-- SET CLASSPATH -->
	<path id="project.class.path">
		<pathelement location="." />
	</path>

	<!-- ENVIRNONMENT PROPERTIES -->
	<property environment="env"/>

<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        Usage
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->

  <target name="usage" unless="silent">
    <echo>
      Supported targets (default=compile):
      -------------------------------------------------------------------------
      compile    - compile project files of the base package.
      compileAll - compile project file of all packages
      binaryDist - create a binary distribution of the base package
      sourceDist - create a source distribution of the base package
      clean      - clean up files, except the source files and the api
                   documentation
      run        - will start EvA2

      use 'ant -projecthelp' for further Main targets
    </echo>
  </target>

<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        Init
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->

  <target name="buildDirectories" unless="noDirectories">
    <mkdir dir="${build.directory}" />
    <mkdir dir="${distribution.directory}" />
    <mkdir dir="${source.distribution.directory}" />
    <mkdir dir="${binary.distribution.directory}" />
    <mkdir dir="${javadoc.directory}" />
  </target>

  <target name="init">
    <tstamp />
    <antcall target="buildDirectories"></antcall>
    <condition property="isWindows">
      <and>
        <os family="windows" />
        <not>
          <os family="unix" />
        </not>
      </and>
    </condition>
    <condition property="isUnix">
      <and>
        <os family="unix" />
        <not>
          <os family="windows" />
        </not>
      </and>
    </condition>
  </target>

<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        Clean
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->

  <target name="clean" description="Cleans up project directories.">
    <delete dir="${build.directory}" />
    <delete dir="${distribution.directory}" />
  </target>

	<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		        Clean JE2Probs
	+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
		<target name="cleanProbs" depends="usage, init, compileInfo" description="Compiles the Probs project." if="JE2Probs.available">
		  	<ant inheritAll="false" antfile="${ant.directory}/build.xml" dir="${JE2Probs.directory}" target="clean">
				<property name="silent" value="true"/>
			</ant>
		</target>
		
	<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		      Clean JE2ESModel
	+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
		<target name="cleanESModel" depends="usage, init, compileInfo" description="Compiles the ESModel project." if="JE2ESModel.available">
		  	<ant inheritAll="false" antfile="${ant.directory}/build.xml" dir="${JE2ESModel.directory}" target="clean">
				<property name="silent" value="true"/>
			</ant>
		</target>
			
  <target name="cleanAll" depends="init, clean, cleanProbs, cleanESModel">
  </target>

<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        CompileAll
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->

  <target name="compileAll" depends="compile, compileProbs, compileESModel, compileResearch" description="Update libraries and compile the project.">
  </target>
	
<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	        Compile Information
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
  <target name="compileInfo" unless="silent">
    <echo message="JE2Base Project"/>
    <echo message="ANT_HOME is set to = ${env.ANT_HOME}"/>
    <echo message="JAVA_HOME is set to = ${env.JAVA_HOME}"/>
    <echo message="You are using JDK version ${ant.java.version}."/>
    <echo message=""/>
    <echo message="use 'ant compileAll' - to compile all packages."/>
    <echo message="use 'ant compile'    - to compile only the base package."/>
  	<echo message="JE2Probs available: ${JE2Probs.available}" />
  	<echo message="JE2ESModel available: ${JE2ESModel.available}" />
 	<echo message="JE2Research available: ${JE2Research.available}" />
  </target>

  <target name="compile" depends="usage, init, compileInfo" description="Compiles the project." >
  <!-- COMPILE PROJECT -->
  <javac destdir="${build.directory}" optimize="on" deprecation="on" nowarn="on" debug="${debug.flag}" >
     <src path="${source.directory}" />
     <exclude name="ant/**" />
     <exclude name="build/**" />
     <exclude name="dist/**" />
     <exclude name="doc/**" />
     <exclude name="resources/**" />
     <exclude name="images/**" />
     <exclude name="lib/**" />
     <exclude name="project/**" />
	 <classpath>
       <pathelement path="${project.class.path}" />
     </classpath>
   </javac>

   <!-- GENERATE RMI STUB FILES -->
   <rmic includes="eva2/tools/jproxy/RMIInvocationHandlerImpl.class"       stubversion="-v1.2" base="${build.directory}"/>
   <rmic includes="eva2/tools/jproxy/RMIThreadInvocationHandlerImpl.class" stubversion="-v1.2" base="${build.directory}"/>

   <!-- COPY DATA FILES TO BUILD DIRECTORY -->
    <copy todir="${build.directory}/resources">
      <fileset dir="${resources.directory}" includes="**/*">
        <exclude name="**/*.xcf" />
      </fileset>
   </copy>
  </target>
	
<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	        Compile JE2Probs
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
	<target name="compileProbs" depends="usage, init, compileInfo" description="Compiles the Probs project." if="JE2Probs.available">
	  	<ant inheritAll="false" antfile="${ant.directory}/build.xml" dir="${JE2Probs.directory}" target="compile">
			<property name="silent" value="true"/>
		</ant>
	</target>
	
<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	        Dist JE2Probs
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
	<target name="distProbs" depends="compileProbs" description="Build dist. of the Probs project." if="JE2Probs.available">
	  	<ant inheritAll="false" antfile="${ant.directory}/build.xml" dir="${JE2Probs.directory}" target="dist">
			<property name="silent" value="true"/>
		</ant>
	</target>
	
<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	      Compile JE2ESModel
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
	<target name="compileESModel" depends="usage, init, compileInfo" description="Compiles the ESModel project (if available)." if="JE2ESModel.available">
	  	<ant inheritAll="false" antfile="${ant.directory}/build.xml" dir="${JE2ESModel.directory}" target="compile">
			<property name="silent" value="false"/>
		</ant>
	</target>

<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	        Dist JE2ESModel
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
	<target name="distESModel" depends="compileESModel" description="Build dist. of the ESModel project (if available)." if="JE2Probs.available">
	  	<ant inheritAll="false" antfile="${ant.directory}/build.xml" dir="${JE2ESModel.directory}" target="dist">
			<property name="silent" value="true"/>
		</ant>
	</target>
	
<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	      Compile JE2Research
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
	<target name="compileResearch" depends="usage, init, compileInfo" description="Compiles the Research project (if available)." if="JE2Research.available">
	 	<ant inheritAll="false" antfile="${ant.directory}/build.xml" dir="${JE2Research.directory}" target="compile">
			<property name="silent" value="false"/>
		</ant>
	</target>
		
<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        Binary Distribution
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
<target name="binaryDist" depends="compile, JEInterface" description="Compiles the project and builds a jar-file.">
    <property name="bin.dist.dir"  value="${binary.distribution.directory}/eva-${DSTAMP}" />
    <mkdir dir="${bin.dist.dir}" />
	<delete>
      <fileset dir="${bin.dist.dir}/" includes="${jar.name}.jar" />
	</delete>

	<jar jarfile="${bin.dist.dir}/${jar.name}.jar"  basedir="${build.directory}" >
	  <manifest> <attribute name="Main-Class" value="eva2.client.EvAClient"/> </manifest>
	</jar>
	
    <copy todir="${distribution.directory}">
      <fileset dir="${bin.dist.dir}">
        <include name="${jar.name}.jar" />
      </fileset>
    </copy>
  </target>

<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        Source Distribution
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->

  <target name="sourceDist" depends="init">
    <property name="src.dist.dir"  value="${source.distribution.directory}/eva2-${DSTAMP}" />
    <mkdir dir="${src.dist.dir}" />
    <copy todir="${src.dist.dir}/${source.directory}">
      <fileset dir="${source.directory}">
      	<include name="**/*java" />
      	<include name="**/*txt" />
      </fileset>
    </copy>
    <copy todir="${src.dist.dir}/${resources.directory}">
      <fileset dir="${resources.directory}">
      	<include name="**/**" />
      </fileset>
    </copy>
    <mkdir dir="${src.dist.dir}/${library.directory}" />
    <copy todir="${src.dist.dir}/${library.directory}">
      <fileset dir="${library.directory}" includes="**jar" />
    </copy>
    <tar tarfile="${distribution.directory}/${srcpack.name}.tar"
         basedir="${src.dist.dir}" includes="**" excludes="*.tar*, *.zip"/>
    <gzip zipfile="${distribution.directory}/${srcpack.name}.tar.gz"
          src="${distribution.directory}/${srcpack.name}.tar" />
    <delete file="${distribution.directory}/${srcpack.name}.tar" />

    <zip zipfile="${distribution.directory}/${srcpack.name}.zip">
      <zipfileset dir="${src.dist.dir}">
        <include name="**" />
        <exclude name="*.tar*, *.zip" />
      </zipfileset>
    </zip>
  </target>

<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        Generate Distribution
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->

  <target name="dist" depends="distESModel, distProbs, binaryDist, sourceDist" description="Builds all distributions if all packages are available.">
  </target>
	
	<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	        Matlab Interface tar.gz to the distribution dir.
	+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->

  <target name="JEInterface">
    <tar tarfile="${matlabinterface.basedir}/${matlabinterface.title}.tar"
         basedir="${matlabinterface.basedir}" includes="**" excludes="*.tar*, *.zip"/>
  	
    <gzip zipfile="${matlabinterface.basedir}/${matlabinterface.title}.tar.gz"
          src="${matlabinterface.basedir}/${matlabinterface.title}.tar" />
    <copy todir="${distribution.directory}">
  	  <fileset dir="${matlabinterface.basedir}">
  		<include name="${matlabinterface.title}.tar.gz" />
  	  </fileset>
  	</copy>
  	<delete file="${matlabinterface.basedir}/${matlabinterface.title}.tar" />
  	<delete file="${matlabinterface.basedir}/${matlabinterface.title}.tar.gz" />
  	  	  	
  </target>

<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        Run EvA2
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->

  <target name="run" description="Runs EvA2.">
    <java classname="eva2.client.EvAClient" fork="yes">
      <jvmarg value="-Xmx512m"/>
      <classpath>
      	<pathelement path="${project.class.path}" />
      	<pathelement path="${build.directory}" />
      	</classpath>
    </java>
  </target>

<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        Javadoc - Unfortunately the java documentation is a bit of a mess. Also check the GUI tip texts.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->

  <target name="javadoc" description="Generates the JavaDoc-API Documentation.">
    <javadoc packagenames="eva2.*"
    windowtitle ="EvA2 API Documentation"
    doctitle    ="EvA2 API Documentation"
    author      ="true"
    version     ="true"
    use         ="true"
    destdir="${javadoc.directory}"
    private     ="true">
            <classpath refid="project.class.path" />
            <sourcepath>
              <pathelement path="${source.directory}" />
            </sourcepath>
            <doctitle><![CDATA[<h1>Test</h1>]]></doctitle>

            <header><![CDATA[<font size="-1"><b><i>
                             <A HREF="http://www.ra.cs.uni-tuebingen.de/software/EvA2/index.html"
                                target="_top">EvA2
                             </A>
                             </b></i></font>]]>
            </header>

        <footer><![CDATA[eva2<br>
                         <A HREF="http://www.ra.cs.uni-tuebingen.de/software/EvA2/index.html"
                            target="_top">EvA2
                         </A>]]>
        </footer>
            <link offline="true"
                  href="http://java.sun.com/j2se/jdk1.5.0_03/docs/api/"
                  packagelistLoc="${env.JAVA_HOME}/docs/api"
            />
            <link href="http://developer.java.sun.com/developer/products/xml/docs/api/"/>
    </javadoc>
  </target>
</project>
<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   END OF FILE
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
