Skip to content

Instantly share code, notes, and snippets.

@sandeepmukho
Last active December 12, 2015 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sandeepmukho/4725685 to your computer and use it in GitHub Desktop.
Save sandeepmukho/4725685 to your computer and use it in GitHub Desktop.
ANT build file that'll copy all the contents of UI folder as is to the destination folder called output (output folder should be created from scratch each time ant build script is run and output folder will be created even if it doesn't exist). All JS and CSS files inside static folder (css and js directories and their sub-directories) needs to …
ui = ui
css = static/css
js = static/js
output = output
product.name = sample
yui = yuicompressor-2.4.8.jar
<project name="SampleBuild-Minify-JS-CSS" default="package" basedir=".">
<description>sample build file to minify js and css files and copy to output directory</description>
<target name="load.properties">
<loadproperties srcFile="ant.properties"/>
</target>
<target name="clean" description="clean up" depends="load.properties">
<!-- Delete the ${output} directory and create one -->
<delete dir="${output}"/>
<mkdir dir="${output}"/>
</target>
<target name="js-concatenate" >
<concat destfile="${output}/${js}/${product.name}.js">
<fileset dir="${ui}/${js}" includes="**/*.js"/>
</concat>
</target>
<target name="css-concatenate" >
<concat destfile="${output}/${css}/${product.name}.css">
<fileset dir="${ui}/${css}" includes="**/*.css"/>
</concat>
</target>
<target name="pre-package" description="Pre Packaging" depends="clean">
<copy todir="${output}">
<fileset dir="${ui}" excludes="**/*.js, **/*.css"/>
</copy>
</target>
<target name="css-minify" depends="pre-package">
<apply executable="java" parallel="false">
<fileset dir="${ui}/${css}" includes="**/*.css" />
<arg line="-jar"/>
<arg path="${yui}"/>
<arg line="--line-break 0"/>
<srcfile/>
<arg line="-o"/>
<mapper type="glob" from="*.css" to="${output}/${css}/*.css"/>
<targetfile/>
</apply>
</target>
<target name="js-minify" depends="pre-package">
<apply executable="java" parallel="false">
<fileset dir="${ui}/${js}" includes="**/*.js" />
<arg line="-jar"/>
<arg path="${yui}"/>
<srcfile/>
<arg line="-o"/>
<mapper type="glob" from="*.js" to="${output}/${js}/*.js"/>
<targetfile/>
</apply>
</target>
<target name="package" depends="css-minify, js-minify" description="generate the package" >
</target>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment