<?xml version="1.0" encoding="UTF-8"?>
<project name="DMDirc-installer" default="default" basedir=".">
    <description>Tasks to build the DMDirc installer.</description>

    <target name="-installer-build" if="has.bash">
        <exec executable="/bin/bash" dir="installer" resultproperty="installer.result">
            <arg value="release.sh"/>
            <arg value="this"/>
        </exec>

        <condition property="installer.success">
            <equals arg1="${installer.result}" arg2="0" />
        </condition>

        <echo message="Installer build finished."/>
        <echo message="Completed build files can be found in:"/>
        <echo message="    ${installer.output.dir}"/>
        <echo message=""/>
    </target>


    <target name="-installer-build-stable" if="has.bash">
        <exec executable="/bin/bash" dir="installer" resultproperty="installer.result">
            <arg value="release.sh"/>
            <arg value="-t"/>
            <arg value="-c"/>
            <arg value="STABLE"/>
            <arg value="--upload"/>
        </exec>

        <condition property="installer.success">
            <equals arg1="${installer.result}" arg2="0" />
        </condition>

        <echo message="Installer build finished."/>
        <echo message="Completed build files can be found in:"/>
        <echo message="    ${installer.output.dir}"/>
        <echo message=""/>
    </target>

    <target name="-installer-build-unstable" if="has.bash">
        <exec executable="/bin/bash" dir="installer" resultproperty="installer.result">
            <arg value="release.sh"/>
            <arg value="-t"/>
            <arg value="-c"/>
            <arg value="UNSTABLE"/>
        </exec>

        <condition property="installer.success">
            <equals arg1="${installer.result}" arg2="0" />
        </condition>

        <echo message="Installer build finished."/>
        <echo message="Completed build files can be found in:"/>
        <echo message="    ${installer.output.dir}"/>
        <echo message=""/>
    </target>
    
    <target name="-installer-nobuild" unless="has.bash">
        <echo message="This task only works on linux"/>
    </target>

    <target name="installer" depends="-installer-nobuild, -installer-build"
            description="Build the installer." />

    <target name="installer-stable" depends="-installer-nobuild, -installer-build-stable"
            description="Build the installer for a stable release." />

    <target name="installer-unstable" depends="-installer-nobuild, -installer-build-unstable"
            description="Build the installer for an unstable release." />


</project>
