Permalink
Browse files

adding build file

  • Loading branch information...
1 parent a8ec725 commit 3e9d52bf6b52322e3397e15b311c667a0512a5ab @addyosmani committed Mar 22, 2011
Showing with 147 additions and 0 deletions.
  1. +147 −0 build.xml
View
147 build.xml
@@ -0,0 +1,147 @@
+<?xml version="1.0" encoding="utf-8"?>
+<project name="tutorialProject" default="prod" basedir="/Users/addy/buildTut/">
+
+ <description>Client-side ANT build file example</description>
+
+ <target name="-load.properties"
+ description="Set properties for this build">
+ <!--YUI Compressor location-->
+ <property name="yui.dir" value="${basedir}/yuicompressor/build/yuicompressor-2.4.2.jar"/>
+ <!--Source JS dir-->
+ <property name="src.js.dir" value="${basedir}/js"/>
+ <!--Source CSS dir-->
+ <property name="src.css.dir" value="${basedir}/css"/>
+ <!--Source Lint/Hint dir-->
+ <property name="jslint.js" value="${basedir}/lint/jshint.js"/>
+ <!--Rhino dir-->
+ <property name="js.jar" value="${basedir}/lint/rhino/js.jar"/>
+ <!--Output dir-->
+ <property name="build.dir" value="build"/>
+ <!--Build version information -->
+ <property name="build.major" value="1"/>
+ <property name="build.minor" value="1"/>
+ </target>
+
+
+
+ <!--Create build directories-->
+ <target name="-init" depends="-load.properties"
+ description="Create build directory structure">
+ <!--Create the time stamp for the new build-->
+ <tstamp>
+ <format property="TODAY" pattern="EEE, d MMM yyyy HH:mm:ss Z"/>
+ </tstamp>
+
+ <!--Delete previous build files-->
+ <delete dir="${build.dir}"/>
+
+ <!--Recreate the build directories-->
+ <mkdir dir="${build.dir}"/>
+ <mkdir dir="${build.dir}/js"/>
+ <mkdir dir="${build.dir}/css"/>
+
+ <!--Log the build timestamps to file-->
+ <echo file="${build.dir}/js/tstamp.txt" append="false">Build Date: ${TODAY}</echo>
+ <echo file="${build.dir}/css/tstamp.txt" append="false">Build Date: ${TODAY}</echo>
+ </target>
+
+
+ <!--JS Lint-->
+ <target depends="-init" name="-js.lint">
+ <pathconvert pathsep=" " property="jsfiles">
+ <fileset dir="${build.dir}/js/">
+ <include name="*.js"/>
+ </fileset>
+ </pathconvert>
+ <exec dir="${build.dir}/js/" executable="java" failonerror="true">
+ <arg line="-jar ${js.jar} ${jslint.js} ${jsfiles}"/>
+ </exec>
+ <echo>Finished</echo>
+ </target>
+
+
+ <!--Concatenate JS files-->
+ <target name="-js.concatenate" depends="-js.lint"
+ description="Concatenates specified JavaScript files">
+ <concat destfile="${build.dir}/js/concat.js">
+ <fileset
+ dir="${src.js.dir}"
+ includes="*.js"
+ excludes="first.js, second.js"/>
+ </concat>
+ <echo>Finished</echo>
+ </target>
+
+
+
+ <!--Concatenate CSS files-->
+ <target name="-css.concatenate" depends="-init"
+ description="Concatenates specified CSS files">
+ <concat destfile="${build.dir}/css/styles.css">
+ <!--first.css and second.css should be first in the concatenated file-->
+ <filelist
+ dir="${src.css.dir}"
+ files="first.css, second.css"/>
+ <!--All of the other files in the directory should appear after.-->
+ <fileset
+ dir="${src.css.dir}"
+ includes="*.css"
+ excludes="first.css, second.css"/>
+ </concat>
+ <echo>Finished</echo>
+ </target>
+
+
+
+ <!--Minify JS files-->
+ <target name="-js.minify" depends="-js.concatenate"
+ description="Minifies JavaScript files">
+ <apply executable="java" parallel="false" dest="${build.dir}/js">
+ <fileset
+ dir="${build.dir}/js"
+ includes="concat.js"/>
+ <arg line="-jar"/>
+ <arg path="${yui.dir}"/>
+ <srcfile/>
+ <arg line="-o"/>
+ <mapper type="glob" from="*.js" to="*-min.js"/>
+ <targetfile/>
+ </apply>
+ <echo>Finished</echo>
+ </target>
+
+
+
+ <!--Minify CSS files-->
+ <target name="-css.minify" depends="-css.concatenate"
+ description="Minifies CSS files">
+ <apply executable="java" parallel="false" dest="${build.dir}/css">
+ <fileset
+ dir="${build.dir}/css"
+ includes="styles.css"/>
+ <arg line="-jar"/>
+ <arg path="${yui.dir}"/>
+ <arg line="--line-break 0"/>
+ <srcfile/>
+ <arg line="-o"/>
+ <mapper type="glob" from="*.css" to="*-min.css"/>
+ <targetfile/>
+ </apply>
+ <echo>Finished</echo>
+ </target>
+
+
+ <!--Build-->
+ <target name="prod"
+ description="Builds project files for production use"
+ depends="
+ -load.properties,
+ -init,
+ -js.concatenate,
+ -js.lint,
+ -css.concatenate,
+ -js.minify,
+ -css.minify">
+ </target>
+</project>
+

0 comments on commit 3e9d52b

Please sign in to comment.