<xsl:comment>clean</xsl:comment>

    <target name="pre-clean"/>
    
    <target name="post-clean"/>

    <target name="-clean-configuration">
        <condition property="can.clean.config.completely">
            <not>
                <equals arg1="${{config.active}}" arg2="" trim="true"/>
            </not>
        </condition>
    </target>
    <target name="-clean-configuration-root" depends="-clean-configuration" if="can.clean.config.completely">
        <delete dir="${{build.dir}}"/>
        <delete dir="${{dist.dir}}"/>
        <available property="dist.dir.exists" file="dist"/>
        <condition property="dist.dir.empty">
            <and>
                <isset property="dist.dir.exists"/>
                <resourcecount count="0">
                    <fileset dir="dist" />
                </resourcecount>
            </and>
        </condition>
    </target>
    <target name="-clean-default-configuration-root" depends="-clean-configuration" unless="can.clean.config.completely">
        <tempfile deleteonexit="true" property="tmp.exclude" prefix="convert"/>
        <echo file="${{tmp.exclude}}">${all.configurations}</echo>
        <replaceregexp file="${{tmp.exclude}}" match="(.)(,|$)" replace="\1/**\2" flags="g"/>
        <loadfile srcfile="${{tmp.exclude}}" property="exclude.pattern"/>
        <delete file="${{tmp.exclude}}"/>
        <delete quiet="true">
            <fileset dir="${{build.dir}}" excludes="${{exclude.pattern}}"/>
        </delete>
        <delete quiet="true">
            <fileset dir="${{dist.dir}}" excludes="${{exclude.pattern}}"/>
        </delete>
        <delete quiet="true">
            <fileset dir="${{dist.dir}}/lib"/>
        </delete>
        <available property="dist.dir.exists" file="dist"/>
        <condition property="dist.dir.empty">
            <and>
                <isset property="dist.dir.exists"/>
                <resourcecount count="0">
                    <fileset dir="dist" />
                </resourcecount>
            </and>
        </condition>

    </target>

    <target name="-clean-completely" if="dist.dir.empty" >
        <delete dir="build" quiet="true" />
        <delete dir="dist" quiet="true" />
    </target>

    <target name="do-clean" depends="__DEPENDS__,-clean-default-configuration-root,-clean-configuration-root,-clean-completely,post-clean"/>

    <target name="clean" depends="conditional-clean" if="no.clean.before.build" description="Clean build products.">
        <antcall target="do-clean" inheritall="true" inheritrefs="true"/>
    </target>
    
