build.xml 5.55 KB
<?xml version="1.0" encoding="UTF-8" ?>
<project name="MTAWeb" basedir="." default="build">
	<property name="source.dir" value="." override="false"/>
	<property name="build.dir" value="build" override="false"/>
	
    <target name="minify">
        <echo msg="Minimizing: ${filename} == ${ifile}" />
        <exec checkreturn="true" command="java -jar ${source.dir}/contrib/webcompress/yuicompressor.jar --preserve-semi ${ifile} -o ${ifile}" />
    </target>
	
	<target name="copy">
	    <delete dir="${source.dir}/${build.dir}" quiet='true' includeemptydirs="true" />
	    <mkdir dir="${source.dir}/${build.dir}" />
	    <copy todir="${source.dir}/${build.dir}" overwrite="true">
	        <fileset dir="${source.dir}">
	            <include name="framework/**" />
	            <include name="public/protected/**" />
	        	<include name="public/images/**" />
	        	<include name="public/index.php" />
	        	<include name="public/.htaccess" />
	        </fileset>
	    </copy>
	</target>
	
	<target name="sass">
        <echo msg="Building css file from sass configuration" />
        <exec command="cd ${source.dir}/public/sass/ &amp;&amp; compass compile" checkreturn="true" />
    </target>
	
	<target name="css" depends="sass">
		<mkdir dir="${build.dir}/public/css" />
		
        <copy todir="public/css" overwrite="true">
            <mapper type="glob" from="*theme.css" to="*theme.min.css"/>
            <fileset dir="public/css">
                <include name="*theme.css" />
            </fileset>
        </copy>
		
        <foreach param="filename" absparam="ifile" target="minify">
            <fileset dir="public/css">
                <include name="*theme.min.css" />
            </fileset>
        </foreach>
		
		<copy todir="${build.dir}/public/css" overwrite="true">
		    <fileset dir="public/css">
		         <include name="*theme*.css" />
		    </fileset>
		</copy>
    </target>
	
	<target name="clear.js">
        <delete includeemptydirs="true" verbose="true" failonerror="true">
            <fileset dir="public/">
                <include name="app/controller/controller.js" />
            	<include name="app/model/model.js" />
            	<include name="app/store/store.js" />
            	<include name="app/view/view.js" />
            	<include name="scripts/app.js" />
                <include name="scripts/app-debug.js" />
             </fileset>
        </delete>
	</target>
	
   	<target name="js" depends="clear.js">
   		<mkdir dir="${build.dir}/public/scripts" />
   		
   	    <fileset dir="public/app/controller" id="controller.set">
   	        <include name="*.js" />
         	<exclude name="controller.js" />
        </fileset>
        <fileset dir="public/app/model" id="model.set">
            <include name="*.js" />
            <exclude name="model.js" />
        </fileset>
        <fileset dir="public/app/store" id="store.set">
            <include name="*.js" />
        	<exclude name="store.js" />
        </fileset>
        
        <append destFile="public/app/controller/controller.js">
            <fileset refid="controller.set" />
        </append>
        <append destFile="public/app/model/model.js">
            <fileset refid="model.set" />
        </append>
        <append destFile="public/app/store/store.js">
            <fileset refid="store.set" />
        </append>
        
        <append destFile="public/app/view/view.js">
        	<filelist dir="public/app/view" files="ProgramMenu.js, Taskpanel.js" />
        	<filelist dir="public/app/view" files="Aliases.js, Alias.js" />
        	<filelist dir="public/app/view" files="Users.js, User.js" />
        	<filelist dir="public/app/view" files="Viewport.js, Authorize.js" />
        	<filelist dir="public/app/view" files="Transports.js" />
        </append>
        
        <append destFile="public/scripts/app-debug.js">
        	<filelist dir="public/app" files="Overrides.js, view/view.js, model/model.js, store/store.js, controller/controller.js, Application.js" />
        </append>
        
        <copy todir="public/scripts" overwrite="true">
        	<mapper type="glob" from="app-debug.js" to="app.js"/>
        	<filelist dir="public/scripts" files="app-debug.js" />
        </copy>
        
        <foreach param="filename" absparam="ifile" target="minify">
        	<filelist dir="public/scripts" files="app.js" />
        </foreach>
   		
   		<copy todir="${build.dir}/public/scripts" overwrite="true">
   			<fileset dir="public/scripts">
   				<include name="**/app.js" />
   				<include name="**/app-debug.js" />
   				<include name="**/ext-all.js" />
   				<include name="**/ext-all-debug.js" />
   			</fileset>
   		</copy>
   	</target>
	
    <target name="build" depends="copy, css, js">
    	<exec checkreturn="true" command="find ${build.dir} -type f -exec chmod 644 {} \;" />
    	<chmod file="${build.dir}/public/protected/runtime" mode="0777" failonerror="true" verbose="true" />
    	
    	<reflexive>
    		<fileset dir="${build.dir}/public">
    			<include name="index.php" />
    		</fileset>
    		<filterchain>
    			<replaceregexp>
    				<regexp pattern="(define[\(\&quot;\'\s]+YII_DEVELOP[\)\,\&quot;\'\s]+)[\w\-\_]+"
    				    replace="\1false" />
    				<regexp pattern="(define[\(\&quot;\'\s]+YII_DEBUG[\)\,\&quot;\'\s]+)[\w\-\_]+"
    				    replace="\1false" />
    			</replaceregexp>
    		</filterchain>
    	</reflexive>
    	
    	<tar destfile="${source.dir}/${build.dir}/mtaweb.tar.gz" compression="gzip">
    		<fileset dir="${source.dir}/${build.dir}">
    			<include name="framework/**" />
    			<include name="public/**" />
    		</fileset>
    	</tar>
    </target>
</project>