<project name="MySQLDumper2" default="build" basedir="./../">

<property name="repodir" value="${basedir}/trunk" />
<property name="logdir" value="${basedir}/build" />

 <target name="clean">
    <delete dir="${lodir}" /> 
    <mkdir dir="${logdir}" /> 
    <mkdir dir="${logdir}/api" /> 
    <mkdir dir="${logdir}/coverage" /> 
    <mkdir dir="${logdir}/logs" /> 
    <mkdir dir="${logdir}/pdepend" /> 
</target>

 <!-- Run unit tests and generate junit.xml and clover.xml -->
 <target name="phpunit">
    <exec dir="${repodir}/tests" executable="phpunit" failonerror="false">
        <arg line="--verbose --config ${repodir}/tests/phpunit.xml" />
    </exec>
 </target>

 <!-- Generate checkstyle.xml -->
 <target name="phpcs">
  <exec executable="phpcs">
   <arg line="--report=checkstyle
              --report-file=${logdir}/logs/checkstyle.xml
              --standard=Zend
              --extensions=php
              --ignore=*/lang.php,*/library/Zend/*,*/library/ZendX/*,*/tests/*
              ./
   "/>
  </exec>
 </target>

<!-- can be used if code sniffer is updated on hudson -->
 <target name="phpcs-new">
  <exec executable="phpcs">
   <arg line="--report=checkstyle
              --report-file=${logdir}/logs/checkstyle.xml
              --standard={repodir}/tests/Zend.xml
              --extensions=php
              --ignore=*/lang.php,*/library/Zend/*,*/library/ZendX/*,*/tests/*
              ./
   "/>
  </exec>
 </target>

  <!-- Generate jdepend.xml and software metrics charts -->
 <target name="pdepend">
    <touch file="${logdir}/logs/jdepend.xml" mkdirs="true" />
    <exec executable="pdepend">
    <arg line="--jdepend-xml=${logdir}/logs/jdepend.xml
        --ignore=language,Zend,ZendX,work,tests
        --suffix=php
        --jdepend-chart=${logdir}/pdepend/dependencies.svg
        --overview-pyramid=${logdir}/pdepend/overview-pyramid.svg
        
        ${repodir}" />
  </exec>
 </target>

 <!-- Generate pmd.xml - exclude */Zend/*,*/language/*    -->
 <target name="phpmd">
    <touch file="${logdir}/logs/pmd.xml" mkdirs="true" />
    <exec executable="phpmd">
        <arg line="./ xml codesize,unusedcode,design,naming
            --reportfile ${logdir}/logs/pmd.xml
            --suffixes php
            --exclude ${repodir}/application/language/*,
                ${repodir}/library/Zend/*,
                ${repodir}/library/ZendX/*,
                ${repodir}/work/*,${repodir}/tests/*
        "/>
  </exec>
 </target>

 <!-- Generate pmd-cpd.xml -->
 <target name="phpcpd">
  <exec executable="phpcpd">
   <arg line="--log-pmd ${logdir}/logs/pmd-cpd.xml
        --suffixes php
        --exclude ${repodir}/library/Zend
        --exclude ${repodir}/application/language
        --exclude ${repodir}/library/ZendX
        --exclude ${repodir}/tests
         ./" />
  </exec>
 </target>

<target name="phploc" description="Generate phploc.csv">
  <exec executable="phploc">
   <arg line="--log-csv ${logdir}/logs/phploc.csv ${repodir}
        --exclude ${repodir}/library/Zend
        --exclude ${repodir}/application/language
        --exclude ${repodir}/library/ZendX
        --exclude ${repodir}/tests
   " />
  </exec>
 </target>


 <!-- Generate API documentation -->
 <target name="phpdoc">
  <exec executable="phpdoc">
   <arg line="-d ${repodir} 
        -t ${logdir}/api 
        -ti 'MySQLDumper2 Code Documentation' 
        -s
        -i language/,Zend/,ZendX/,*.phtml,tests/,index.php,flag.php,Debug.php,bootstrap.php,work/" />
  </exec>
 </target>
</project>


