Ant Build Scripts

Continuing the theme of my last two posts, today I will write about how I am gradually improving my skills in another area of software engineering. This time it is Ant Build Scripts. I've completed the following eight exercises.

1. Ant Hello World: simply prints "Hello World"
2. Ant Immutable Properties: demonstrates ant properties
3. Ant Dependencies: shows how dependencies are resolved
4. Hello Ant Compilation: compiles a simple "Hello Ant" program
5. Hello Ant Execution: executes the "Hello Ant" program
6. Hello Ant Documentation: creates javadocs for the "Hello Ant" program
7. Cleaning Hello Ant: cleans the "Hello Ant" build directory
8. Packaging Hello Ant: creates a zip file of the "Hello Ant" project

I had worked briefly with CruiseControl in an internship a few years ago so I was familiar with the types of tasks that could be done with build systems, but I had never written the scripts myself. At the time, the scripts seemed cryptic and complicated. However, the five exercises that compile and run the "Hello Ant" program above were fairly easy to write and short. For example, the following script is all that is needed to compile the program.


<project default="compile">
<target name="compile">
<javac srcdir="src" destdir="build\classes" />
</target>
</project>


As this was my first time writing Ant, I spent the majority of my time in the documentation figuring out what attributes to use for each task. After creating Ant build scripts for one or two more projects, these basic exercises could be finished within a few minutes. This time could be more than made up for in savings from repeated compilations and executions as the project evolves. I look forward to expanding my knowledge in Ant scripting by creating tasks for testing and quality assurance. I expect them to be as easy to setup as the tasks above, and they should prevent me from making obvious errors or forgetting to run each test whenever I update my code.

Although I didn't use it in these exercises, I think the Ivy dependency manager is a neat tool. The ability for the build system to manage layers of dependencies, while only downloading each external dependency once, could be incredibly useful. Instead of wondering "I think I installed that once... but what version? And where did I save it?" then spending valuable time searching through past projects or searching the internet for the correct download (and then repeating the process for each transitive dependency) Ivy handles it all.

After doing a few projects like this, I'm sure I'll be wondering how I lived without build systems for so many years. 

Comments

Popular posts from this blog

Working with Esper: Problems and Solutions

Writing and Testing FizzBuzz in Eclipse

WattDepot Katas