Chapter 5. Building Eclipse Projects Using Ant
Eclipse is great for building your code. But for more advanced project development, there’s still something missing. For example, what if you want not only to compile several files at once, but also to copy files over to other build directories, create JAR files and Javadoc, create new directories, delete previous builds, and create deployment packages all at once?
You can do that with a build tool like Apache’s Ant (http://ant.apache.org /). Ant is a Java-based build tool that can perform all these tasks and much more. You can download Ant and run it on the command line, automating your build tasks to not only compile code, but to create JAR files, move and create classes, delete and make directories, and a great deal more.
The good news here is that Ant comes built into Eclipse, ready to use. Ant is the premier build tool for Java development, and we’ll get an idea why in this chapter. As your projects become more and more elaborate, Ant can automate dozens of tasks that you’d otherwise need to perform manually. When you have things set up to run with Ant, all you’ve got to do is point and click to perform a complete build without having to take dozens of separate steps, which can save many steps omitted in error over the development process.
The fact that Ant comes built into Eclipse means that it’s easier to use for us than for all those developers who use it on the command line. To see how this works, we’ll start with a quick example. ...