1. Michael Gatto
  2. VersionControl_Hg

Source

VersionControl_Hg / src / Scripts / Build / build.xml

The default branch has multiple heads

<?xml version="1.0" encoding="UTF-8"?>
<project name="vchgbuild" default="main" basedir="../../"
    description="Release and PEAR packaging build process for VersionControl_Hg">

    <property name="rootdir" value="H:" />
    <property name="docsdir" value="Documentation" />
    <property name="sourcedir" value="/" override="true" />
    <property name="codedir" value="VersionControl" />
    <property name="unittestsdir" value="/Tests/Unit" />
    <property name="cruisecontroldir" value="C:\Program Files\Cruisecontrol\projects\VersionControl_Hg" />

    <!-- <input propertyname="version">Which version tag are we deploying?</input> -->

    <taskdef classname="phing.tasks.ext.d51PearPkg2Task" name="d51pearpkg2" />

    <!--  -->
    <target name="main" depends="quality,pear-package" description="">
    </target>

    <!--  -->
    <target name="quality" depends="sniffs,copy-paste,mess-detector,lines-of-code,code-browser,metrics" description="">
        <echo message="Generating all quality documentation" />
    </target>

    <!--  -->
    <target name="pear-package" depends="deploy-to-release,create-package-xml,tar,post" description="">
    </target>

    <!-- Clean the Releases dir -->
    <target name="clean-release-dir" description="Clean the Releases dir">
        <!--  depends="" -->
        <delete dir="${rootdir}/Releases/PEAR/" includeemptydirs="true" verbose="true" />
    </target>

    <!-- create the pear package skeleton structure -->
    <target name="pear-structure" depends="clean-release-dir" description="Create the pear package skeleton structure">
        <mkdir dir="${rootdir}/Releases/PEAR/VersionControl_Hg" />
        <mkdir dir="${rootdir}/Releases/PEAR/VersionControl_Hg/tests" />
        <mkdir dir="${rootdir}/Releases/PEAR/VersionControl_Hg/docs" />
        <mkdir dir="${rootdir}/Releases/PEAR/VersionControl_Hg/docs/examples" />
        <!--<mkdir dir="${rootdir}/Releases/PEAR/VersionControl_Hg/scripts" />-->
        <!--<mkdir dir="${rootdir}/Releases/PEAR/VersionControl_Hg/misc" />-->
        <!--<mkdir dir="${rootdir}/Releases/PEAR/VersionControl_Hg/data" />-->
        <mkdir dir="${rootdir}/Releases/PEAR/VersionControl_Hg/VersionControl/" />
    </target>

    <target name="deploy-to-release" depends="pear-structure">
        <copy todir="${rootdir}/Releases/PEAR/VersionControl_Hg/VersionControl/">
            <fileset dir="VersionControl">
                <include name="**/*.php" />
            </fileset>
        </copy>
        <copy todir="${rootdir}/Releases/PEAR/VersionControl_Hg/docs">
            <fileset dir="Documentation/API/Docbook">
                <include name="**/*.xml" />
            </fileset>
        </copy>
        <copy todir="${rootdir}/Releases/PEAR/VersionControl_Hg/docs/examples">
            <mapper type="regexp" from="^(test_)(.*)\.php" to="\2.php"/>
            <!--<mapper type="glob" from="test_*.php" to="*.php"/>-->
            <fileset dir="Tests/Functional">
                <include name="**/*.php" />
            </fileset>
        </copy>
        <copy todir="${rootdir}/Releases/PEAR/VersionControl_Hg/tests/unit">
            <fileset dir="Tests/Unit">
                <include name="**/*.php" />
            </fileset>
            <filelist dir="Tests/" files="phpunit.xml" />
        </copy>
    </target>

    <!--  -->
    <target name="create-package-xml" depends="deploy-to-release" description="">
        <d51pearpkg2 baseinstalldir="/" dir="${rootdir}/Releases/PEAR/VersionControl_Hg">
            <name>VersionControl_Hg</name>
            <summary>A Php5 interface to Mercurial repositories</summary>
            <channel>pear.php.net</channel>
            <description>VersionControl_Hg provides a fluid interface with natural semantics to allow Php programmers to interact with Mercurial repositories. An excellent use case is in checking out projects as part of a build process.</description>
            <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD</license>
            <lead user="mgatto" name="Michael Gatto" email="mgatto@lisantra.com" />
            <version release="${version}" api="${version}" />
            <stability release="beta" api="beta" />
            <notes>-</notes>
            <dependencies>
                <php minimum_version="5.2.0" />
                <pear minimum_version="1.7.0" recommended_version="1.9.1" />
            </dependencies>

            <dirroles key="examples">doc</dirroles>
            <dirroles key="docs">doc</dirroles>

            <changelog version="0.3.0" api_version="0.3.0" date="2011-01-01">
                * Made it work again
            </changelog>
            <changelog version="0.4.0" api_version="0.4.0" date="2011-06-01">

            </changelog>
            <changelog version="0.5.0" api_version="0.5.0" date="2011-08-01">

            </changelog>
        </d51pearpkg2>
    </target>

    <!--  -->
    <target name="tar" depends="create-package-xml" description="">
        <exec command="pear package" dir="${rootdir}/Releases/PEAR/VersionControl_Hg/" passthru="true" />
    </target>

    <!-- Checksums for tgz. packages -->
    <target name="build_checksums">
        <echo msg="Creating MD5 and SHA1 checksums..." />
        <exec escape="false" command="echo -----------------md5sums----------------- >> ${rootdir}/Releases/PEAR/VersionControl_Hg/VersionControl_Hg-${version}.tgz.md5" />
        <exec escape="false" command="md5sum ${rootdir}/Releases/PEAR/VersionControl_Hg/*.tgz >> ${rootdir}/Releases/PEAR/VersionControl_Hg/VersionControl_Hg-${version}.tgz.md5" />

        <exec escape="false" command="echo -----------------sha1sums----------------- >> ${rootdir}/Releases/PEAR/VersionControl_Hg/VersionControl_Hg-${version}.tgz.md5" />
        <exec escape="false" command="sha1sum ${rootdir}/Releases/PEAR/VersionControl_Hg/*.tgz >> ${rootdir}/Releases/PEAR/VersionControl_Hg/VersionControl_Hg-${version}.tgz.md5" />

        <!--not sure why this is here: <exec escape="false" command="cat ${checksumpath}.tmp | sed 's!${rootdir}/Releases/PEAR/VersionControl_Hg/!!g' > ${checksumpath}.txt" />-->
    </target>

    <target name="post" depends="tar" description="">
        <move file="${rootdir}/Releases/PEAR/VersionControl_Hg/VersionControl_Hg-${version}.tgz" tofile="${rootdir}/Releases/VersionControl_Hg-${version}.tgz" overwrite="true" />
        <phingcall target="clean-release-dir" />
    </target>

<!-- CODE QUALITY & METRICS tasks -->

    <!-- runs unit tests on code in dev area, not the Releases folder (change?) -->
    <target name="test" description="" depends="">
        <exec command="phpunit
            --log-xml ${cruisecontroldir}\build\logs\phpunit.xml
            --log-pmd ${cruisecontroldir}\build\logs\phpunit.pmd.xml
            --log-metrics ${cruisecontroldir}\build\logs\phpunit.metrics.xml
            --coverage-xml ${cruisecontroldir}\build\logs\phpunit.coverage.xml
            --coverage-html ${cruisecontroldir}\build\coverage
            --configuration ..\phpunit.xml ."
            dir="Tests/Unit" passthru="true" />

        <!-- noframes  -->
        <phpunitreport infile="${docsdir}\Quality\test-reports\junit-log.xml"
            format="frames"
            todir="${docsdir}\Quality\test-reports\html"
            styledir="C:\Languages\Php\data\phing\etc" />
    </target>

    <!-- Hmmm, very very spurious results; it seems not to handle magic functions well at all -->
    <target name="dead-code">
        <exec dir="${codedir}" command="phpdcd --recursive --suffixes php >> ${docsdir}\Quality\dead-code\summary.txt" passthru="true"/>
    </target>

    <!-- run code-sniffs -->
    <target name="sniffs">
        <phpcodesniffer standard="PEAR">
            <fileset dir="${codedir}">
                <include name="**/*.php" />
            </fileset>
            <formatter type="summary" outfile="${docsdir}/Quality/code-sniffs/summary.txt" />
            <formatter type="csv" outfile="${docsdir}/Quality/code-sniffs/checkstyle.csv" />
            <formatter type="checkstyle" outfile="${cruisecontroldir}/build/logs/checkstyle.xml"/>
        </phpcodesniffer>
    </target>

    <!-- Generate pmd-cpd.xml -->
    <target name="copy-paste">
        <phpcpd>
            <fileset dir="${codedir}" id="files-to-cpd">
                <include name="**/*.php" />
            </fileset>
            <formatter type="default" outfile="${docsdir}/Quality/copy-paste/summary.txt" />
            <formatter type="pmd" outfile="${cruisecontroldir}/build/logs/pmd-cpd.xml" />
        </phpcpd>
    </target>

    <!-- Generate pmd.xml -->
    <target name="mess-detector">
        <phpmd rulesets="codesize,unusedcode,design,naming">
            <fileset dir="${codedir}">
                <include name="**/*.php" />
            </fileset>
            <formatter type="html" outfile="${docsdir}/Quality/mess-detector/messes.html"/>
            <formatter type="text" outfile="${docsdir}/Quality/mess-detector/summary.txt"/>
            <formatter type="xml" outfile="${cruisecontroldir}/build/logs/pmd.xml"/>
        </phpmd>
    </target>

    <!-- Generate phploc.csv -->
    <target name="lines-of-code">
        <taskdef name="phploc" classname="phing.tasks.ext.PhpLocTask" />
        <phploc reportType="txt" reportName="lines"
            reportDirectory="${docsdir}/Quality/lines-of-code/" countTests="false" >
            <fileset dir="${codedir}">
                <include name="**/*.php" />
            </fileset>
        </phploc>

        <phploc reportType="xml" reportName="loc"
            reportDirectory="${cruisecontroldir}/build/logs/" countTests="false" >
            <fileset dir="${codedir}">
                <include name="**/*.php" />
            </fileset>
        </phploc>
    </target>

    <!-- Generate browsable code -->
    <target name="code-browser" depends="">
        <echo message="Generating browsable code locally" />
        <exec command="phpcb --source ${basedir}\${codedir} --output ${basedir}\${docsdir}\Code" passthru="true" />

        <echo message="Generating browsable code for PhpUnderControl" />
        <exec command="phpcb --log ${cruisecontroldir}\build\logs\ --source ${basedir}\${codedir} --output ${cruisecontroldir}\build\php-code-browser" />
    </target>

    <!-- pdepend -->
    <target name="metrics">
        <phpdepend>
            <fileset dir="${codedir}">
                <include name="**/*.php" />
            </fileset>
            <!-- ${docsdir}/Quality/metrics/summary.xml -->
            <logger type="summary-xml" outfile="${cruisecontroldir}/build/logs/pdepend.xml"/>
            <!--<logger type="phpunit-xml" outfile="${docsdir}/Quality/metrics/pdepend.xml"/>-->
            <logger type="overview-pyramid" outfile="${cruisecontroldir}/build/charts/overview-pyramid.svg"/>
            <logger type="jdepend-chart" outfile="${cruisecontroldir}/build/charts/jdepend.svg"/>
            <analyzer type="coderank-mode" value="inheritance,property,method"/>
        </phpdepend>
    </target>

    <!-- API Documentation -->
    <target name="docs">
        <echo msg="Cleaning docs dir" />
        <delete dir="${docsdir}/Api" includeemptydirs="true" verbose="false" failonerror="false" />

        <echo msg="Making docs dir" />
        <mkdir dir="${docsdir}" />
        <mkdir dir="${docsdir}/API/Docbook" />
        <mkdir dir="${docsdir}/API/Html" />

        <echo message="Making Html edition" />
        <exec command="phpdoc --title VersionControl_Hg --parseprivate on -d H:\Development\_Webroot\Trunk\VersionControl -t H:\Development\_Webroot\Trunk\Documentation\API\Html -o HTML:frames:default --examplesdir H:\Development\_Webroot\Trunk\Tests\Functional --readmeinstallchangelog" escape="false" />

        <echo message="Making PHPUnderControl edition" />
        <!--  -ct type -->
        <exec command="phpdoc --parseprivate on -ue on -t ${cruisecontroldir}\build\api -tb C:\Languages\Php\data\phpUnderControl\data\phpdoc -o HTML:Phpuc:phpuc --title VersionControl_Hg -d H:\Development\_Webroot\Trunk\VersionControl --examplesdir H:\Development\_Webroot\Trunk\Tests\Functional --readmeinstallchangelog" escape="false" />

        <echo message="Making Docbook edition" />
        <exec command="phpdoc --title VersionControl_Hg --parseprivate on -d H:\Development\_Webroot\Trunk\VersionControl -t H:\Development\_Webroot\Trunk\Documentation\API\Docbook -o XML:DocBook/peardoc2:default --examplesdir H:\Development\_Webroot\Trunk\Tests\Functional --readmeinstallchangelog" escape="false" />
    </target>

    <!-- Tutorials -->
    <target name="tutorials">
        <echo message="Cleaning out generated HTML Docs" />
        <delete dir="${docsdir}/Docbook/html" />

        <mkdir dir="${docsdir}/Docbook/html" />

        <echo message="Making HTML tutorials" />
        <exec command="phd -x -P PEAR -f xhtml -r -o ${docsdir}/Docbook/html -d ${docsdir}/Docbook/src/versioncontrol-hg.xml" escape="false" />
    </target>

</project>