Comparing Maven and Ant
Although the previous section should convince you that the authors of this book have no interest in creating a feud between Apache Ant and Apache Maven, we are cognizant of the fact that most organizations have to make a decision between Ant and Maven. In this section, we compare and contrast the tools.
Ant excels at build process; it is a build system modeled after
make with targets and dependencies. Each target
consists of a set of instructions that are coded in
XML. There is a copy task and a
javac task as well as a jar
task. When you use Ant, you supply it with specific instructions for
compiling and packaging your output. Look at the simple build.xml file shown in Example 1-1.
Example 1-1. A simple Ant build.xml file
<project name="my-project" default="dist" basedir="."> <description> simple example build file </description> <!-- set global properties for this build --> <property name="src" location="src/main/java"/> <property name="build" location="target/classes"/> <property name="dist" location="target"/> <target name="init"> <!-- Create the time stamp --> <tstamp/> <!-- Create the build directory structure used by compile --> <mkdir dir="${build}"/> </target> <target name="compile" depends="init" description="compile the source " > <!-- Compile the java code from ${src} into ${build} --> <javac srcdir="${src}" destdir="${build}"/> </target> <target name="dist" depends="compile" description="generate the distribution" > <!-- Create the distribution directory ...