Ant - Building Projects

Now that we have learnt about the data types in Ant, it is time to put that knowledge into action. We will build a project in this chapter. The aim of this chapter is to build an Ant file that compiles the java classes and places them in the WEB-INF\classes folder.

Consider the following project structure:

The database scripts are stored in the db folder.

The java source code is stored in the src folder.

The images, js, META-INF, styles (css) are stored in the war folder.

The JSPs are stored in the jsp folder.

The third party jar files are stored in the lib folder.

The java class files are stored in the WEB-INF\classes folder.

This project forms the Hello World Fax Application for the rest of this tutorial.

Finally, the build target to build the files. First of all, we create the build directory, if it does not exist. Then we execute the javac command (specifying jdk1.5 as our target compilation). We supply the source folder and the classpath to the javac task and ask it to drop the class files in the build folder.