Skip to content

Instantly share code, notes, and snippets.

@taclab
Created September 19, 2012 14:59
Show Gist options
  • Select an option

  • Save taclab/3750125 to your computer and use it in GitHub Desktop.

Select an option

Save taclab/3750125 to your computer and use it in GitHub Desktop.
Buil XML for ANT APACHE
<?xml version="1.0" encoding="utf-8"?>
<project name="tutorialProject" default="prod" basedir=".">
<description>Client-side ANT build file example</description>
<target name="-load.properties"
description="Set properties for this build">
<!--Google Compiler location-->
<property name="gcomp.dir" value="${basedir}/shared/bin/google-compiler.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}/shared/bin/jshint.js"/>
<!--Rhino dir-->
<property name="js.jar" value="${basedir}/shared/bin/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"/>
<!--Log the build timestamps to file-->
<echo file="${build.dir}/js/tstamp.txt" append="false">Build Date: ${TODAY}</echo>
</target>
<!--JS Lint-->
<target depends="-init" name="-js.lint">
<echo message="Lint js files... " />
<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">
<echo message="Concatenate js files..." />
<concat destfile="${build.dir}/js/concat.js">
<fileset
dir="${src.js.dir}"
includes="*.js"
/>
</concat>
<echo>Finished</echo>
</target>
<!--Minify JS files-->
<target name="-js.minify" depends="-js.concatenate">
<echo message="Minifing js files..." />
<apply executable="java" parallel="false" verbose="true" dest="${build.dir}/js">
<fileset
dir="${build.dir}/js"
includes="concat.js"/>
<arg line="-jar" />
<arg path="${gcomp.dir}" />
<arg value="--warning_level" />
<arg value="QUIET" />
<arg value="--compilation_level" />
<arg value="ADVANCED_OPTIMIZATIONS" />
<arg value="--js_output_file" />
<targetfile />
<arg value="--js" />
<mapper type="glob" from="*.js" to="*.min.js" />
</apply>
<echo>Finished</echo>
</target>
<!--Build-->
<target name="prod"
description="Builds project files for production use"
depends="
-load.properties,
-init,
-js.concatenate,
-js.lint,
-js.minify">
</target>
</project>
<!-- -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment