<?xml version="1.0" encoding="UTF-8"?>
<project name="LawCarta wordpress project" default="build-without-tests">

 <target name="build-without-tests"
         depends="composer_install, replace, archive"
         description="Build project and run all tests"/>

<target name="replace"
        unless="replace.done"
        description="Replace placeholders in config files" >

    <replace dir="../environments" token="@lcAwsKey@" value="${lcAwsKey}"/>
    <replace dir="../environments" token="@lcAwsSecretKey@" value="${lcAwsSecretKey}"/>

    <replace dir="../environments" token="@lcWpMySqlHostDev@" value="${lcWpMySqlHostDev}"/>
    <replace dir="../environments" token="@lcWpMySqlDbnameDev@" value="${lcWpMySqlDbnameDev}"/>
    <replace dir="../environments" token="@lcWpMySqlUsernameDev@" value="${lcWpMySqlUsernameDev}"/>
    <replace dir="../environments" token="@lcWpMySqlPasswordDev@" value="${lcWpMySqlPasswordDev}"/>

    <replace dir="../environments" token="@lcWpMySqlHostQA@" value="${lcWpMySqlHostQA}"/>
    <replace dir="../environments" token="@lcWpMySqlDbnameQA@" value="${lcWpMySqlDbnameQA}"/>
    <replace dir="../environments" token="@lcWpMySqlUsernameQA@" value="${lcWpMySqlUsernameQA}"/>
    <replace dir="../environments" token="@lcWpMySqlPasswordQA@" value="${lcWpMySqlPasswordQA}"/>

    <replace dir="../environments" token="@lcWpMySqlHostDemo@" value="${lcWpMySqlHostDemo}"/>
    <replace dir="../environments" token="@lcWpMySqlDbnameDemo@" value="${lcWpMySqlDbnameDemo}"/>
    <replace dir="../environments" token="@lcWpMySqlUsernameDemo@" value="${lcWpMySqlUsernameDemo}"/>
    <replace dir="../environments" token="@lcWpMySqlPasswordDemo@" value="${lcWpMySqlPasswordDemo}"/>

    <replace dir="../environments" token="@lcWpMySqlHostStaging@" value="${lcWpMySqlHostStaging}"/>
    <replace dir="../environments" token="@lcWpMySqlDbnameStaging@" value="${lcWpMySqlDbnameStaging}"/>
    <replace dir="../environments" token="@lcWpMySqlUsernameStaging@" value="${lcWpMySqlUsernameStaging}"/>
    <replace dir="../environments" token="@lcWpMySqlPasswordStaging@" value="${lcWpMySqlPasswordStaging}"/>

    <replace dir="../environments" token="@lcWpMySqlHostProd@" value="${lcWpMySqlHostProd}"/>
    <replace dir="../environments" token="@lcWpMySqlDbnameProd@" value="${lcWpMySqlDbnameProd}"/>
    <replace dir="../environments" token="@lcWpMySqlUsernameProd@" value="${lcWpMySqlUsernameProd}"/>
    <replace dir="../environments" token="@lcWpMySqlPasswordProd@" value="${lcWpMySqlPasswordProd}"/>

    <property name="replace.done" value="true"/>
</target>

<target name="composer_install">
    <exec dir="${basedir}/.." executable="composer" failonerror="true">
        <arg line="install" />
    </exec>
</target>

<target name="archive">
    <tar compression="gzip" destfile="lc_wp.tar.gz" longfile="posix">
        <tarfileset dir="${basedir}/..">
            <include name="*/**" />
            <exclude name="build/**" />
        </tarfileset>
    </tar>
</target>

</project>

