Thursday, September 29, 2011

My Experience with Ant Build Systems

I have recently been learning about the XML-based build system known as Ant and how it can improve your Java projects.  Ant is a build system that is primarily designed for Java, which allows you access to a wide range of project management capabilities.  Similar to the Unix Make command, you can set dependencies for targets and Ant will only compile or process certain required tasks that need to be done, rather than doing everything again each time you call it.  You can automate a great deal of XML scripting in order to better manage your project files or even generate javadoc files.

Thus far, I have completed a number of Kata exercises for Ant, which have helped me learn a lot more about Ant's usefulness.  Listed below are 8 very basic katas that each covers a different aspect of Ant build systems:

1. Ant Hello World 
This Kata covers basic structure of an Ant basic XML file.  It simply echos "Hello World".

2. Ant Immutable Properties
This Kata covers basic Ant properties and how they cannot be changed after they have been set.

3. Ant Dependencies
This one dealt with dependencies and how they work.
 
4. Hello Ant Compilation
This one compiled a java file "HelloAnt.java" and placed the class file into another directory.
 
5. Hello Ant Execution
This is the Kata with which I had an issue.  It is supposed to simply run the compiled "HelloAnt" program, but for some reason I couldn't understand how to set up the classpath properly and was met with several errors.  The execution target depends on the file being already compiled, which I didn't have any problems with.

6. Hello Ant Documentation
This generates all of the javadoc files for the project.
 
7.  Cleaning Hello Ant
This exercise simply deletes all of the build directories that the previous Ant scripts generate.

8. Packaging Hello Ant
This exercise creates a zip file for the current directory and all of its sub-directories.  It depends on the compilation, execution, documentation, and then cleans the build directory before creating the zip file.  As I was unable to get my execution script to work properly, I left that dependency out of the equation for now.  I intend to go back and add that once I determine why my execution script did not work.
 
Overall, it was a rewarding experience to delve into XML and learn how to work with targets, dependencies, paths, and even how to manipulate file structures and directories.  Once I figure out how to fix my error with the execution script, I will be able to fully set up a build system for future projects from scratch.  All that is left now is to go over information regarding testing and automated quality assurance.  After I cover those basics, working with large projects should be much easier to deal with.
 

No comments:

Post a Comment