<project name="Myrmidon audit" default="main" basedir=".">

    <property file="host.properties"/>
    <property file="user.properties"/>
    <property file="project.properties"/>
    <property file="workspace.properties"/>

    <property name="output.dir" value="output"/>
    <property name="audit.dir" value="${output.dir}/audit"/>
    <property name="audit.xml" location="${audit.dir}/audit.xml"/>
    <property name="metrics.dir" value="${output.dir}/metrics"/>
    <property name="metrics.xml" value="${metrics.dir}/metrics.xml"/>
    <property name="audit.fix" location="false"/>

    <!-- custom Audit rules -->
    <path id="custom-rules">
        <pathelement location="${metamata.home}/rules"/>
    </path>

    <path id="project.class.path">
      <pathelement path="${java.class.path}" />
      <fileset dir="lib">
        <include name="*.jar" />
      </fileset>
    </path>

    <target name="main" depends="audit" description="Do audit"/>

    <target name="update" description="Update module source code">
        <echo message="Updating module ${project.dir}..."/>
        <cvs command="update" dest="${project.dir}"/>
    </target>

    <target name="audit">
        <mkdir dir="${audit.dir}"/>
        <maudit tofile="${audit.xml}" fix="${audit.fix}" metamatahome="${metamata.home}">
<!--            <rulespath refid="custom-rules"/>-->
            <classpath refid="project.class.path"/>
            <sourcepath path="${project.src.path}"/>
            <fileset dir="src/java" includes="**/*.java"/>
            <fileset dir="src/main" includes="**/*.java"/>
        </maudit>
    </target>

    <target name="metrics" description="Source code metrics">
        <mkdir dir="${metrics.dir}"/>
        <mmetrics tofile="${metrics.xml}" metamatahome="${metamata.home}" granularity="methods">
            <classpath refid="project.class.path"/>
            <sourcepath path="${project.src.path}"/>
            <path path="${project.src.path}"/>
        </mmetrics>
    </target>

    <!--
      ==========================================================================
      Common targets
      ==========================================================================
    -->

    <target name="publish-audit" description="Publish Audit results">
        <echo message="Generating results..."/>
        <style in="${audit.xml}" out="null.tmp" style="maudit-frames.xsl">
            <param name="output.dir" expression="${audit.dir}"/>
        </style>

        <echo message="Generating e-mail body..."/>
        <style in="${audit.xml}" out="${audit.dir}/mail.txt" style="maudit-mail.xsl">
            <param name="project.url" expression="${project.url}"/>
        </style>
    </target>

    <target name="publish-metrics" description="Publish Metric results">
        <echo message="Generating metrics results..."/>
        <style in="${metrics.xml}" out="null.tmp" style="mmetrics-frames.xsl">
            <param name="output.dir" expression="${metrics.dir}"/>
        </style>

        <echo message="Generating metrics e-mail body..."/>
        <style in="${metrics.xml}" out="${metrics.dir}/mail.txt" style="metrics-mail.xsl">
            <param name="project.url" expression="${project.url}"/>
        </style>
    </target>

    <target name="sendmail">
        <mail from="${mail.from}" tolist="${mail.to}" mailhost="${mail.host}"
            subject="${mail.subject}" messagefile="${mail.file}"/>
    </target>

</project>