build.xml 3.76 KB
<?xml version="1.0" encoding="UTF-8" ?>
<project name="MyMailAdmin" basedir="." default="build">
    <property name="src_dir" value="protected/" override="false"/>
    <property name="build.dir" value="public/" override="false"/>
	<property name="pkg" value="/tmp/mailadmin" override="false"/>
    
    <target name="require">
        <echo msg="This build requires:" />
        <echo msg="Compass framework" />
        <echo msg="YUI Compressor" />
    </target>
    
	<target name="minify">
	    <echo msg="Minimizing: ${filename}" />
	    <exec command="java -jar yuicompressor.jar ${ifile} -o ${ifile}" />
	</target>
	
    <target name="sass">
        <echo msg="Building css file from sass configuration" />
        <delete includeemptydirs="true" verbose="true" failonerror="true">
            <fileset dir="${build.dir}/css">
                <include name="*.css" />
            </fileset>
        </delete>
        <exec command="cd ${build.dir}/sass/ &amp;&amp; compass compile" checkreturn="true" />
        <delete dir="${build.dir}/css/sass" includeemptydirs="true" verbose="true" failonerror="true" />
    </target>
    
    <target name="css" depends="sass">
    	<echo msg="CSS compiled" />
    	<copy todir="${build.dir}/css" overwrite="true">
    		<mapper type="glob" from="*.css" to="*.min.css"/>
    		<fileset dir="${build.dir}/css">
    			<include name="*.css" />
    	    </fileset>
    	</copy>
    	<foreach param="filename" absparam="ifile" target="minify">
    		<fileset dir="${build.dir}/css">
    		    <include name="*.min.css" />
    		</fileset>
    	</foreach>
    </target>
    
	<target name="clear.js">
		<delete includeemptydirs="true" verbose="true" failonerror="true">
			<fileset dir="${build.dir}">
				<include name="app/controller/controller.js" />
				<include name="app/view/view.js" />
				<include name="app/model/model.js" />
				<include name="scripts/app-debug.js" />
			</fileset>
		</delete>
	</target>
	
	<target name="js" depends="clear.js">
	    <fileset dir="${build.dir}/app/controller" id="controller.set">
	    	<include name="*.js" />
	    	<exclude name="controller.js" />
	    </fileset>
		<fileset dir="${build.dir}/app/model" id="model.set">
    		<include name="*.js" />
    		<exclude name="model.js" />
		</fileset>
		<fileset dir="${build.dir}/app/store" id="store.set">
    		<include name="*.js" />
    		<exclude name="store.js" />
		</fileset>
		
		<append destFile="${build.dir}/app/controller/controller.js">
			<fileset refid="controller.set" />
		</append>
		<append destFile="${build.dir}/app/model/model.js">
		    <fileset refid="model.set" />
		</append>
		<append destFile="${build.dir}/app/store/store.js">
		    <fileset refid="store.set" />
		</append>
		
		<append destFile="${build.dir}/app/view/view.js">
			<filelist dir="${build.dir}/app/view" files="ProgramMenu.js, Taskpanel.js" />
			<filelist dir="${build.dir}/app/view" files="Aliases.js, Alias.js" />
			<filelist dir="${build.dir}/app/view" files="Users.js, User.js" />
			<filelist dir="${build.dir}/app/view" files="Viewport.js, Authorize.js" />
			<filelist dir="${build.dir}/app/view" files="Transports.js" />
		</append>
		
		
		<append destFile="${build.dir}/scripts/app-debug.js">
			<filelist dir="${build.dir}/app" files="Overrides.js, view/view.js, model/model.js, store/store.js, controller/controller.js, Application.js" />
	    </append>
		
		<copy todir="${build.dir}/scripts" overwrite="true">
			<mapper type="glob" from="app-debug.js" to="app.js"/>
			<filelist dir="${build.dir}/scripts" files="app-debug.js" />
		</copy>
		
		<foreach param="filename" absparam="ifile" target="minify">
			<filelist dir="${build.dir}/scripts" files="app.js" />
		</foreach>
	</target>
	
    <target name="build" depends="require, css, js">
        <echo msg="All done." />
    </target>
</project>