Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

391 lines (314 sloc) 13.956 kb
<?xml version="1.0"?>
<project name="Meru Logo" default="build" basedir="../"> <!-- one back since we're in build/ -->
<!-- load property files -->
<property file="build/build.properties"/>
<property file="build/default.properties"/>
<!-- there are three different options for html optimization:
buildkit : all html whitespace retained. inline script/style minified
htmlclean (default) : minor html optimizations (extra quotes removed). inline script/style minified
htmlcompress : html minification
-->
<target name="basics" depends="clean,copy,usemin,js.all,css,html" description="Concats files, runs YUI Compressor on them and makes magic happen."/>
<target name="text" depends="basics,htmlclean" description="Concats files, runs YUI Compressor on them and makes magic happen."/>
<target name="buildkit" depends="basics,htmlbuildkit" description="Concats files, runs YUI Compressor, optimizes images. There is much rejoicing."/>
<target name="build" depends="basics,htmlclean" description="Concats files, runs YUI Compressor, optimizes images. There is much rejoicing."/>
<target name="minify" depends="basics,htmlcompress" description="Concats files, runs YUI Compressor, optimizes images. There is much rejoicing."/>
<!--
Wipe the old
-->
<target name="clean">
<echo message="Cleaning up previous build directory..."/>
<delete dir="./${dir.publish}/"/>
</target>
<!--
Copy in the new stuff
-->
<target name="copy" depends="clean">
<echo message="Copying over new files..."/>
<copy todir="./${dir.publish}">
<fileset dir="./${dir.source}">
<exclude name=".gitignore"/>
<exclude name=".project"/>
<exclude name=".settings"/>
<exclude name="README.markdown"/>
<exclude name="**/.git/**"/>
<exclude name="**/.svn/**"/>
<exclude name=".gitignore"/>
<exclude name="*.conf*"/>
<exclude name="mime.types"/>
<exclude name="**/${dir.build}/**"/>
<exclude name="**/${dir.test}/**"/>
<exclude name="**/${dir.demo}/**"/>
<exclude name="**/${dir.js}/profiling/**"/>
<!-- configurable excludes -->
<exclude name="**/${file.exclude}/**"/>
</fileset>
</copy>
</target>
<!-- Optimize javascript files
-->
<target name="js.all" depends="js.remove.console, js.all.min, js.main.concat, js.concat.scripts, js.minifyonly.min, js.delete"></target>
<!--
JS: Concat primary scripts
-->
<target name="js.main.concat" depends="js.all.min">
<echo message="Concatenating JS scripts"/>
<concat destfile="./${dir.publish}/${dir.js}/scripts.js">
<fileset dir="./${dir.publish}/">
<include name="**/${dir.js.main}/*.min.js"/>
<exclude name="**/${dir.js.libs}/*.js"/>
</fileset>
</concat>
</target>
<!--
JS: Concat library scripts
-->
<!-- Comment out console.log commands from main scripts -->
<target name="js.remove.console" description="Comment out console.log lines">
<echo>Commenting out console.log lines</echo>
<replaceregexp match="(console.log\(.*\))" replace="/\*\1\*/" flags="g" >
<fileset dir="./${dir.publish}/${dir.js}/">
<include name="**/*.js"/>
<exclude name="**/*.min.js"/>
</fileset>
</replaceregexp>
</target>
<!--
JS: Minify primary scripts and libraries
-->
<target name="js.all.min" depends="copy">
<echo message="Minifying concatenated script- and library-file"/>
<apply executable="java" parallel="false">
<fileset dir="./${dir.publish}/${dir.js}">
<include name="*.js"/>
<exclude name="*.min.js"/>
<exclude name="**/${dir.js.libs}/*.js"/>
</fileset>
<arg line="-jar"/>
<arg path="./${dir.tools}/${tool.yuicompressor}"/>
<srcfile/>
<arg line="--line-break"/>
<arg line="4000"/>
<arg line="-o"/>
<mapper type="glob" from="*.js" to="../${dir.publish}/${dir.js}/*.min.js"/>
<targetfile/>
</apply>
</target>
<!--
JS: Minify helper files.
these files do not get concat'd with anyone else.
they will get a build number in their filename though
-->
<target name="js.minifyonly.min">
<echo message="Minifying helper JS files"/>
<apply executable="java" parallel="false">
<fileset dir="./${dir.publish}/${dir.js.libs}/" includes="*.js" excludes="*.min.js"/>
<arg line="-jar"/>
<arg path="./${dir.tools}/${tool.yuicompressor}"/>
<srcfile/>
<arg line="-o"/>
<mapper type="glob" from="*.js" to="../${dir.publish}/${dir.js.libs}/*.min.js"/>
<targetfile/>
</apply>
</target>
<!--
JS: Concat mylibs- and scripts- into a normal and a debug file.
Then rename them to s/-all//
-->
<target name="js.concat.scripts" if="build.concat.scripts">
<echo message="Concatenating library file with main script file"/>
<concat destfile="./${dir.publish}/${dir.js}/scripts.min.js">
<fileset dir="./${dir.publish}/${dir.js}/">
<include name="libs.js"/>
<include name="scripts.js"/>
</fileset>
</concat>
<echo message="Concatenating library file with main debug script file"/>
<concat destfile="./${dir.publish}/${dir.js}/scripts-debug.min.js">
<fileset dir="./${dir.publish}/${dir.js}/">
<include name="libs.js"/>
<include name="scripts-debug.js"/>
</fileset>
</concat>
<echo>About to rename scripts-all to scripts</echo>
<!--
<move file="./${dir.publish}/${dir.js}/scripts-all.min.js" tofile="./${dir.publish}/${dir.js}/scripts.min.js"/>
<move file="./${dir.publish}/${dir.js}/scripts-all-debug.min.js" tofile="./${dir.publish}/${dir.js}/scripts-debug.min.js"/>
-->
</target>
<!--
JS: Delete unoptimized files (If set)
-->
<target name="js.delete" if="build.delete.unoptimized" depends="js.if.concat.scripts">
<echo message="Deleting unoptimized files"/>
<delete file="./${dir.publish}/${dir.js}/scripts.js"/>
<delete file="./${dir.publish}/${dir.js}/scripts-debug.js"/>
<delete includeemptydirs="true">
<fileset dir="./${dir.publish}/${dir.js.libs}/" includes="*.js" excludes="*.min.js"/>
<fileset dir="./${dir.publish}/${dir.js}/" includes="*.js" excludes="*.min.js"/>
</delete>
</target>
<!-- JS, Delete concatenated libs file (only if concat.scripts and delete.unoptimized are defined) -->
<target name="js.if.concat.scripts" if="build.delete.unoptimized, build.concat.scripts">
<delete file="./${dir.publish}/${dir.js}/libs.min.js"/>
<delete file="./${dir.publish}/${dir.js}/scripts.min.js"/>
</target>
<!--
CSS: concat style.css into ... one file. :)
run it through yui compressor for minification.
replace the reference to it in index.html
-->
<target name="css" depends="copy">
<echo message="Minifying css..."/>
<concat destfile="./${dir.publish}/${dir.css}/style.css">
<fileset file="./${dir.source}/${dir.css}/style.css"/>
</concat>
<apply executable="java" parallel="false">
<fileset dir="./${dir.publish}/${dir.css}/" includes="style.css"/>
<arg line="-jar"/>
<arg path="./${dir.tools}/${tool.yuicompressor}"/>
<srcfile/>
<arg line="-o"/>
<mapper type="glob" from="style.css" to="../${dir.publish}/${dir.css}/style.min.css"/>
<targetfile/>
</apply>
<replace token="style.css" value="style.min.css" file="./${dir.publish}/${file.index}"/>
<!-- <delete file="./publish/css/style.css"/> -->
</target>
<!--
IMAGES: png
-->
<target name="imagespng" depends="copy">
<echo message="Optimizing images"/>
<apply executable="optipng" osfamily="unix">
<arg value="-o7"/>
<fileset dir="./${dir.publish}/">
<include name="**/*.png"/>
</fileset>
</apply>
<apply executable="optipng" osfamily="mac">
<arg value="-o7"/>
<fileset dir="./${dir.publish}/">
<include name="**/*.png"/>
</fileset>
</apply>
<apply executable="tools/optipng-0.6.4-exe/optipng.exe" osfamily="windows">
<arg value="-o7"/>
<fileset dir="./${dir.publish}/">
<include name="**/*.png"/>
</fileset>
</apply>
</target>
<!--
IMAGES: jpg
-->
<target name="imagesjpg" depends="copy">
<echo message="Clean up those jpgs..."/>
<apply executable="jpegtran" osfamily="unix">
<fileset dir="./${dir.publish}/${dir.images}/" includes="*.jpg"/>
<arg value="-copy"/>
<!-- change 'all to 'none' in order to strip metadata
only do so if you own copyright to the image -->
<arg value="all"/>
<srcfile/>
<targetfile/>
<!-- you may want to flag optimized images. If so, do it here. Otherwise change this to type="identity" -->
<mapper type="glob" from="*.jpg" to="../${dir.publish}/${dir.images}/*.jpg"/>
</apply>
<apply executable="jpegtran" osfamily="mac">
<fileset dir="./${dir.publish}/${dir.images}/" includes="*.jpg"/>
<arg value="-copy"/>
<!-- change 'all to 'none' in order to strip metadata
only do so if you own copyright to the image -->
<arg value="all"/>
<srcfile/>
<targetfile/>
<!-- you may want to flag optimized images. If so, do it here. Otherwise change this to type="identity" -->
<mapper type="glob" from="*.jpg" to="../${dir.publish}/${dir.images}/*.jpg"/>
</apply>
<apply executable="tools/jpegtran.exe" osfamily="windows">
<fileset dir="./${dir.publish}/${dir.images}/" includes="*.jpg"/>
<arg value="-copy"/>
<!-- change 'all to 'none' in order to strip metadata
only do so if you own copyright to the image -->
<arg value="all"/>
<srcfile/>
<targetfile/>
<!-- you may want to flag optimized images. If so, do it here. Otherwise change this to type="identity" -->
<mapper type="glob" from="*.jpg" to="../${dir.publish}/${dir.images}/*.jpg"/>
</apply>
</target>
<!--
HTML: switch to minified jquery in the html
-->
<target name="usemin" depends="copy">
<echo message="Switching to minified js files..."/>
<!-- switch from a regular jquery to minified-->
<replaceregexp match="jquery-(\d|\d(\.\d)+)\.js" replace="jquery-\1.min.js" file="./${dir.publish}/${file.index}" flags=""/>
<!-- switch any google CDN reference to minified -->
<replaceregexp match="(\d|\d(\.\d)+)\/jquery\.js" replace="\1/jquery.min.js" file="./${dir.publish}/${file.index}" flags=""/>
<echo>kill off those versioning flags: ?v=2</echo>
<replaceregexp match='\?v=\d+">' replace='">' file="./${dir.publish}/${file.index}" flags=""/>
</target>
<!--
HTML: replaces scripts with single concat'd one.
removes profiling code
-->
<target name="html" depends="">
<echo message="Clean up the html..."/>
<!-- style.css replacement handled as a replacetoken above -->
<replaceregexp match="&lt;!-- START CONCAT [\d\w\s\W]*?!-- END CONCAT --&gt;" file="./${dir.publish}/${file.index}" replace="&lt;script src='${dir.js}/scripts.min.js\'&gt;&lt;/script&gt;" flags="m"/>
<replaceregexp match="&lt;!-- yui profiler[\d\w\s\W]*?end profiling code --&gt;" file="./${dir.publish}/${file.index}" replace=" " flags="m"/>
<!--[! use comments like this one to avoid having them get minified -->
</target>
<!--
HTML Minification. There are three levels. htmlclean is default.
-->
<target name="htmlbuildkit" depends="html" >
<apply executable="java" parallel="false" force="true" dest="./${dir.publish}/" >
<fileset dir="./${dir.publish}/" includes="*.html"/>
<arg value="-jar"/>
<arg path="./${dir.build}/tools/htmlcompressor-0.9.3.jar"/>
<arg value="--preserve-comments"/>
<arg line="--preserve-multi-spaces"/>
<arg line="--type html"/>
<arg line="--compress-js"/>
<arg line="--compress-css"/>
<srcfile/>
<arg value="-o"/>
<mapper type="glob" from="*.html" to="../${dir.publish}/*.html"/>
<targetfile/>
</apply>
</target>
<target name="htmlclean" depends="html" >
<apply executable="java" parallel="false" force="true" dest="./${dir.publish}/" >
<fileset dir="./${dir.publish}/" includes="*.html"/>
<arg value="-jar"/>
<arg path="./${dir.build}/tools/htmlcompressor-0.9.3.jar"/>
<arg line="--type html"/>
<arg line="--preserve-multi-spaces"/>
<arg line="--remove-quotes"/>
<arg line="--compress-js"/>
<arg line="--compress-css"/>
<srcfile/>
<arg value="-o"/>
<mapper type="glob" from="*.html" to="../${dir.publish}/*.html"/>
<targetfile/>
</apply>
</target>
<target name="htmlcompress" depends="html" >
<apply executable="java" parallel="false" force="true" dest="./${dir.publish}/" >
<fileset dir="./${dir.publish}/" includes="*.html"/>
<arg value="-jar"/>
<arg path="./${dir.build}/tools/htmlcompressor-0.9.3.jar"/>
<arg line="--type html"/>
<arg line="--remove-quotes"/>
<arg line="--compress-js"/>
<arg line="--compress-css"/>
<srcfile/>
<arg value="-o"/>
<mapper type="glob" from="*.html" to="../${dir.publish}/*.html"/>
<targetfile/>
</apply>
</target>
</project>
Jump to Line
Something went wrong with that request. Please try again.