Ant and Make
Archive - Originally posted on "The Horse's Mouth" - 2006-04-22 08:06:46 - Graham EllisIn order to produce a file of answers in many applications, you need to take several files of inputs and run a program to generate the results. The inputs themselves may be answers produced by running further programs on further inputs, and so on until you have a whole huge tree of inputs that are used to produce a single (or relatively few) file of answers.
What do you do if an input is changed? Well - you have to run all the programs again and produce fresh intermediate answers, from which you can go on and produce new final results. If it's something you do frequently, you can automate the whole business through a shell script or batch file.
But in a big system, you'll be repeating a lot of needless work in your shell script on many occasions. If only one input has been altered, it's unlikely that all the branches of your tree will need to be rebuilt - you'll really only need to rebuild the sections of the tree below where the inputs have changed and to do the whole thing could be a huge waste of resources.
Both Ant and Make are tools that help you do only the work that you need. In both cases, you specify the structure of the build tree though:
• "target"s - the answer files - at all levels - that you'll be writing
• a number of "sources" for each target - input files which, if changed mean the target must be remade
• actions (commands) that need to be run to produce the target from the sources
Then, when you run your ant or make, it compares the timestamps on the source files with those on the current target if it exists, and runs the actions if necessary. Missing targets will always cause an action to be run, and targets that become new sources for further actions will trigger off that further action as well.
If you've defined your tree well in a file called build.xml (ant) or makefile, all you need do to modify your answer file is to make any appropriate changes to the input files and type ant or make. Might take a while to set up in the first place, but once you've got a system running, the efficiency is unbelievable!
Ant is a Java tool and is used extensively in creating Java applications for the web - files such as .jar .war and .ear resources - for deployment through Tomcat, JBoss and other tools. Make is primarily a Unix / Linux tool that's traditionally used for building programs from sources, and installing those programs