Thursday, September 29, 2011

Let's mess around with ANT!

On our continuous journey through the glamorous and exciting world of software engineering, we come across another valuable programming tool, which goes by the name of ANT. And yes, while those tiny insects that scrounge the earth may come to mind upon hearing this name, it's actually an acronym standing for "Another Neat Tool". So the whole insect thing was actually just an afterthought, as it turns out. Anyways, so what exactly does this ANT do? Well simply put, it's an Apache-built automated software build tool, which given the right commands, can automatically compile java files, alter directories, grab updates and modules and whatnot from the internet and place them in the proper system directories on your computer, and that's just the tip of the iceberg. It's as if it gives you the power of an ant-whisperer of sorts, where you tell the ants what you want to be done and they just all go off and do what you told them to do. For more fun facts on ANT, here you go.

In order to get our feet wet with ANT, we were assigned 8 little katas to figure out and compile. Some took more time than others, but for the most part they were all relatively straight-forward.  In order to complete these katas, we had to make various build files, which were to be done in XML(ANT uses xml files to execute commands and whatnot). Although lacking in prior experience with the language, the resources provided online, including the apache ant website and tutorials pages proved to be of great assistance in helping me to get off the ground.

There are a couple of special things about ANT that I noticed while going through the katas. Why some of these things are present in ANT I do not know, but they're just things that you're going to have to get used to. For example, properties, which can be thought of as variables, are immutable in ANT, meaning that once you've declared something, you can't change the value, which was the point of one of the katas.

Another interesting feature of ANT is dependencies, which are pretty much what targets, which can be thought of as methods, need to do in order for them to run. For example, if I had a target="foo" that had a dependency on another target="bar", denoted by depends="bar", that means that in order for "foo" to run, "bar" must first be run. Even though the code for "foo" might be written before the code for "bar", when compiled, "bar" is run first, followed by "foo". It's a pretty interesting feature of ANT.

Another thing that ANT allows you to do is to run features from JAVA from within ANT. This includes compiling java files, running java files, and even generating javadocs, all of which were some of the katas assigned.  In order for ANT to be able to use the features from java, however, it's important to make sure that java is properly installed on your computer, and that all your environmental variables are inputted correctly.  This proved to be a minor setback for me completing all of the katas, but eventually I was able to find the errors and fix them accordingly.

Well, that just about sums up my experiences with ANT thus far, and my impressions thus far is that it's a pretty powerful development tool to use, and if done right, it can make one's job as a software developer a lot less difficult.

No comments:

Post a Comment