<?xml version="1.0" encoding="UTF-8"?>
<project name="DMDirc" default="default" basedir=".">
    <description>Builds, tests, and runs the project DMDirc.</description>

    <available file="/bin/bash" property="has.bash"/>

    <import file="nbproject/build-impl.xml"/>
    <import file="build-installer.xml"/>
    <import file="build-jar.xml"/>
    <import file="build-plugins.xml"/>
    <import file="build-reports.xml"/>
    <import file="build-tests.xml"/>
    <import file="build-versioning.xml"/>

    <target name="-submodules" depends="-submodules-bash, -submodules-default"/>

    <target name="-check-use">
        <!-- Use script iff:
               - bash is available
               - submodule.update is set to true
        -->
        <condition property="use.bash.submodule">
            <and>
                <equals arg1="${submodule.update}" arg2="true" />
                <equals arg1="${has.bash}" arg2="true" />
            </and>
        </condition>
        
        <!-- Use git's built in commands iff:
             - submodule.update is set to true
             - bash is not available
        -->
        <condition property="use.default.submodule">
            <and>
                <equals arg1="${submodule.update}" arg2="true" />
                <equals arg1="${has.bash}" arg2="false" />
            </and>
        </condition>
    </target>


    <target name="-submodules-bash" depends="-check-use" if="use.bash.submodule">
        <exec executable="/bin/bash">
            <arg value="updateSubModules.sh"/>
        </exec>
    </target>

    <target name="-submodules-default" depends="-check-use" if="use.default.submodule">
        <exec executable="git">
            <arg value="submodule"/>
            <arg value="init"/>
        </exec>
        <exec executable="git">
            <arg value="submodule"/>
            <arg value="update"/>
        </exec>
    </target>

    <target name="-pre-init" depends="-submodules"/>
    <target name="-post-compile" depends="-write-version, build-plugins, -addpluginlibs"/>
    <target name="-post-test-run" depends="-do-test-reports"/>
    <target name="-post-jar" depends="-addjarlibs"/>

</project>
