staempfli/magento2-builder-tool

View on GitHub
build/xmlscripts/util.xml

Summary

Maintainability
Test Coverage
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
 * util.xml
 *
 * @copyright Copyright (c) 2016 Staempfli AG
 * @author    juan.alonso@staempfli.com
 */
-->
<project name="Util" default="..." basedir=".">

    <target name="util:properties"
            hidden="true">

        <property file="${application.startdir}/../_conf/environment.properties"/>
        <property file="${application.startdir}/config/project.properties"/>
        <property file="${application.startdir}/config/mg2-builder/build.properties"/>
        <property file="${phing.dir}/build/config/default.properties"/>

        <if>
            <not>
                <isset property="project.name" />
            </not>
            <then>
                <!-- If not set, get the project name automatically as the project root directory -->
                <exec command="basename ${application.startdir}" outputProperty="project.name"/>
            </then>
        </if>

        <customHook hook="after-read-properties"/>
    </target>

    <target name="util:environment"
            hidden="true">

        <if>
            <isset property="project.environment"/>
            <then>
                <echo message="Local environment already set to ${project.environment}"/>
            </then>
            <else>
                <input propertyName="project.environment" validArgs="${project.environment.valid}"
                       message="Local Environment: "/>
            </else>
        </if>
    </target>

    <target name="util:db:clean"
            depends="util:properties,
            database:properties,
            tests-setup:properties,
            magento:cache:clean,
            database:drop,
            tests-setup:integration:db:drop"
            hidden="true">

        <customHook hook="after-util-db-clean"/>

        <echo message="Clean up databases done"/>
    </target>

    <target name="util:check:output"
            description="Checks that output from command does not contain errors"
            hidden="true">
        <if>
            <or>
                <and>
                    <contains string="${check.output}" substring="error" casesensitive="false"/>
                    <not><contains string="${check.output}" substring="errors: 0" casesensitive="false"/></not>
                </and>
                <contains string="${check.output}" substring="denied" casesensitive="false"/>
                <contains string="${check.output}" substring="failed" casesensitive="false"/>
                <contains string="${check.output}" substring="Exception" casesensitive="false"/>
                <contains string="${check.output}" substring="is undefined in file" casesensitive="false"/>
            </or>
            <then>
                <echo message="${check.output}" level="error"/>
                <fail message="Command failed" />
            </then>
            <else>
                <echo message="Output does not contain any errors" />
            </else>
        </if>
    </target>

</project>