<?xml version="1.0" encoding="UTF-8"?>

<project name="TMCSim" default="package-jars" basedir=".">
    <description>Builds, tests, and runs the project TMCSim.</description>
    <property name="workdir" value="../.."/>
<!--        STORE SUBVERSION BUILD STRING      -->
<!-- Store the Subversion version string every time you do clean/build. -->
<target name="-pre-compile">
  <exec executable="svnversion" osfamily="unix"
    output="${workdir}/config/svn-version.txt"/>
    <echo file="${workdir}/config/svn-version.txt" append="true">
        # Do not edit. This file is autogenerated by the Ant build script #
    </echo>
</target>
<!--
                =================
                LOC counter 
                =================
-->
<target description="Count Lines of Code in src directory." name="loc">
        <java classname="textui.LOC"
        classpath="${workdir}/lib/JavaLOC.jar">
               <arg line="-r -d ${workdir}/src"/>
  </java>    
</target>    
<!--
                =================
                CHECKSTYLE SECTION
                =================
     -->
<target description="Run checkstyle on src directory." name="checkstyle">
<taskdef resource="checkstyletask.properties"
         classpath="${workdir}/lib/customcheckstylechecks.jar;${workdir}/lib/checkstyle-all-4.4.jar"/>
<checkstyle config="${workdir}/lib/jdstyle.xml" failOnViolation="true">
            <!-- Specify includes and excludes -->
            <fileset dir="${workdir}/src/tmcsim" includes="**/*.java"
            />
</checkstyle>
</target>     
   
<!--
                =================
                PACKAGE JARS SECTION
                =================
-->
<target description="Build separate jar files for each component of the TMC system." 
        name="package-jars">

    <!--         *** Build a jar with everything ***            -->
    <property name="deploy.jar.name" value="TMCSimAll"/>
    <property name="deploy.dir" value="deploy"/>
    <property name="deploy.jar" value="${deploy.dir}/${deploy.jar.name}.jar"/>
    <property name="build.dir" value="../../"/>



    <delete dir="${deploy.dir}"/>
    <mkdir dir="${deploy.dir}"/>

    
    <!--                   *** Build CAD Server Only Jar ***         -->
      <jar destfile="${deploy.dir}/CADserver.jar"
       basedir="${build.dir}/bin"
       includes="tmcsim/cadsimulator/**, tmcsim/common/**, tmcsim/interfaces/**,
                 tmcsim/client/cadclientgui/**, tmcsim/cadmodels/**"
       excludes="**/Test.class">
        <zipgroupfileset dir="${workdir}/lib" includes="xercesImpl.jar"/>
        <manifest>
            <attribute name="Main-Class" value="tmcsim.cadsimulator.CADSimulator"/>
        </manifest>
      </jar>

      <!--                   *** Build Sim Manager Only Jar ***         -->
      <jar destfile="${deploy.dir}/SimManager.jar"
       basedir="${build.dir}/bin"
       includes="tmcsim/simulationmanager/**, tmcsim/common/**, tmcsim/cadmodels/**,
            tmcsim/client/cadclientgui/**, tmcsim/interfaces/**"
       excludes="**/Test.class">
        <zipgroupfileset dir="${workdir}/lib" includes="xercesImpl.jar"/>
        <manifest>
            <attribute name="Main-Class" value="tmcsim.simulationmanager.SimulationManager"/>
        </manifest>
      </jar>

      <!--                   *** Build CAD Client Only Jar ***         -->
      <jar destfile="${deploy.dir}/CADClient.jar"
       basedir="${build.dir}/bin"
       includes="tmcsim/client/**, tmcsim/common/**, tmcsim/interfaces/**, 
            tmcsim/cadmodels/**">
        <zipgroupfileset dir="${workdir}/lib" includes="xercesImpl.jar"/>
        <manifest>
            <attribute name="Main-Class" value="tmcsim.client.CADClient"/>
        </manifest>
      </jar>
      <!-- Remove the following line when we get CADClient to run 
      <delete file="${deploy.dir}/CADClient.jar"/>-->
      
      <!--                   *** Build Paramics Communicator Only Jar ***         -->
      <jar destfile="${deploy.dir}/ParamicsCommunicator.jar"
       basedir="${build.dir}/bin"
       includes="tmcsim/paramicscommunicator/**, tmcsim/common/**,
                 tmcsim/paramicslog/**"
       excludes="**/Test.class">
        <zipgroupfileset dir="${workdir}/lib" includes="xercesImpl.jar"/>
        <manifest>
            <attribute name="Main-Class" value="tmcsim.paramicscommunicator.ParamicsCommunicator"/>
        </manifest>
      </jar>
</target>
    
</project>
