<?xml version="1.0" encoding="UTF-8"?>
<project name="jquery.simple-color" default="jquery.simple-color" basedir=".">
    
    <tstamp />
    
    <loadfile property="version" srcfile="VERSION"/>
    
    <property description="Folder for jquery.simple-color and min target" name="dist" value="."/>
    <property name="JQS" value="${dist}/jquery.simple-color.js"/>
    <property name="JQS_MIN" value="${dist}/jquery.simple-color.min.js"/>
    
    <target name="jquery.simple-color" description="Main jquery.simple-color build, concatenates source files and replaces @VERSION">
        <echo message="Building ${JQS}"/>
        <mkdir dir="${dist}"/>
        <concat destfile="${JQS}">
            <fileset file="src/jquery.simple-color.js"/>
        </concat>
        <replaceregexp match="@VERSION" replace="${version}" flags="g" byline="true" file="${JQS}"/>
        <replaceregexp match="@DATE" replace="${DSTAMP}${TSTAMP}" file="${JQS}"/>
        <echo message="${JQS} built."/>
    </target>
    
    <target name="min" depends="jquery.simple-color" description="Remove all comments and whitespace, no compression, great in combination with GZip">
        <echo message="Building ${JQS_MIN}"/>
        <apply executable="java" parallel="false" verbose="true" dest="${dist}">
            <fileset dir="${dist}">
                <include name="jquery.simple-color.js"/>
            </fileset>
            <arg line="-jar"/>
            <arg path="build/compiler.jar"/>
            <arg value="--warning_level"/>
            <arg value="QUIET"/>
            <arg value="--js_output_file"/>
            <targetfile/>
            <arg value="--js"/>
            <mapper type="glob" from="jquery.simple-color.js" to="tmpmin"/>
        </apply>
        <concat destfile="${JQS_MIN}">
            <filelist files="${JQS}, tmpmin"/>
            <filterchain>
                <headfilter lines="11"/>
            </filterchain>
        </concat>
        <concat destfile="${JQS_MIN}" append="yes">
            <filelist files="tmpmin"/>
        </concat>
        <delete file="tmpmin"/>
        <echo message="${JQS_MIN} built."/>
    </target>
    
    <target name="clean">
        <delete dir="tmpmin"/>
    </target>
    
</project>
