<?xml version="1.0" encoding="UTF-8"?>
<project name="smsapi-php-client" default="build" basedir=".">
    <target name="build" depends="clean,composer,lint,phpunit,apigen"/>
    <target name="clean" description="Cleanup build artifacts">
        <delete file="${basedir}/composer.lock"/>
        <delete dir="${basedir}/docs"/>
    </target>
    <target name="composer" description="Install dependencies">
        <exec executable="wget" failonerror="true">
            <arg value="-nc" />
            <arg value="http://getcomposer.org/composer.phar" />
        </exec>
        <exec executable="php">
            <arg value="composer.phar" />
            <arg value="self-update" />
        </exec>
        <exec executable="php" failonerror="true">
            <arg value="composer.phar" />
            <arg value="install" />
        </exec>
    </target>
    <target name="lint" description="Perform syntax check of sourcecode files">
        <apply executable="php" failonerror="true">
            <arg value="-l" />
            <fileset dir="${basedir}">
                <include name="smsapi/*.php" />
                <include name="test/*.php" />
                <modified />
            </fileset>
        </apply>
    </target>
    <target name="phpunit" description="Run unit tests with PHPUnit">
        <exec executable="php" failonerror="true">
            <arg value="${basedir}/vendor/bin/phpunit" />
            <arg value="--configuration" />
            <arg path="${basedir}/build/phpunit.xml" />
        </exec>
    </target>
    <target name="apigen" description="Generate docs">
        <exec executable="php" failonerror="false">
            <arg value="${basedir}/vendor/bin/apigen" />
            <arg value="generate" />
            <arg value="--source" />
            <arg path="${basedir}/smsapi" />
            <arg value="--destination" />
            <arg path="${basedir}/docs" />
            <arg value="--title" />
            <arg value="SMSAPI Api Client" />
        </exec>
    </target>
</project>
