Automation with open standards

In the past, my development tool-chain relied heavily on an IDE and build tools to provide automation services, Eclipes/Java/Ant, C#/Visual Studio/nAnt, and ActionScript /Eclipse/FDT/Ant.

Moving to open standard development projects, the road to automation was not so clear. But with research and perseverance I have been able to find a solution. While it presently contains the bare necessities (documentation, validation, unit testing, and repetitive tasks like minifiying, concatenation, etc), I am sharing it with all of you on Github (see below for links)  with the hope that it will benefit others. I looked into ways of using Ant (a common build tool used in java) and to my surprise there were already some “Ant tasks” that allow a simple integration. Also I created a few tasks to help me with common and not so common tasks. Nowadays I am using Ant builds to do various things.

Css/JS Minification – To do minification I am using the YUICompressor. There is an open source project called js-build-tools that has a collection of ant tasks. So on all I need to do is include the task definitions (that will point to the jars) and then call the task:

<yuicompress infile=”somefile.js” outfile=”somefile.min.js” />

You can also create a target that calls the jar directly:
<target name=”minify_js”>
       <apply executable=”java” parallel=”false”>
              <fileset dir=”../js” includes=”*.js” excludes=”**/*.min.js,**/*.preprocessed.js” />         
              <arg line=”-jar”/>
              <arg path=”./lib/yuicompressor.jar”/>        
              <arg line=”-o”/>
              <mapper type=”glob” from=”*.js” to=”../js/*.min.js”/>

The js-build-tools collection also comes with a documentation tool for javascript and a preprocessor engine that allows you to add statements in you code that get process at “compile” time. So you can add different code for debug and release versions.

Custom tasks – There are a large number of Ant tasks that developers have build to do things like JSLint, SVN, zipping files, etc. but a at times I need something custom, like adding a disclaimer to all my javascript/css/html files. To do this I created a custom Ant tasks in java. The java class has to extend and implement the public “execute” method. The class then needs to be compiled and put in a jar file with a properties file that describes the name of the task and the path to the class.

What’s next- Is that all? Not really, my plan is to continue adding new tasks to the projects so I can automatically run unit tests, code coverage, css/html validation, build css sprites and more! When working on a big project, and for continuous integration, you can combine this with other tools like Maven and Hudson. Hudson can pull the data from your repository and quickly run the builds and keep it in a common place for the rest of the team.

Demo links
Demo project:

Generated documentation:

Ant build file:

Custom Ant task