<project name="MySQLDumper2" default="build" basedir="/home/jenkins/msd">

<property name="repodir" value="${basedir}/svn" />
<property name="builddir" value="${basedir}/build" />
<property name="logdir" value="${basedir}/build/logs" />

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

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

<!-- Run Code Sniffer and check coding style -->
 <target name="phpcs">
  <exec executable="phpcs">
   <arg line="--report=checkstyle
              --report-file=${logdir}/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}/jdepend.xml" mkdirs="true" />
    <exec dir="${repodir}" executable="pdepend">
    <arg line="--jdepend-xml=${logdir}/jdepend.xml
        --ignore=language,Zend,ZendX,work,tests
        --suffix=php
        --jdepend-chart=${builddir}/pdepend/dependencies.svg
        --overview-pyramid=${builddir}/pdepend/overview-pyramid.svg
        
        ${repodir}" />
  </exec>
 </target>

 <!-- Generate pmd.xml - exclude */Zend/*,*/language/*    -->
 <target name="phpmd">
    <touch file="${logdir}/pmd.xml" mkdirs="true" />
    <exec dir="${repodir}" executable="phpmd">
        <arg line="${repodir}/ xml codesize,unusedcode,design,naming
            --reportfile ${builddir}/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 dir="${repodir}" executable="phpcpd">
   <arg line="--log-pmd ${logdir}/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}/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 ${builddir}/api
        -ti 'MySQLDumper2 Code Documentation'
        -s
        -i language/,Zend/,ZendX/,*.phtml,tests/,index.php,flag.php,Debug.php,bootstrap.php,work/" />
  </exec>
 </target>
</project>
