Running Ant
We are going to assume that Ant is installed properly. If you have any doubts on this point, now is the time to read Chapter 2 and get everything up and running.
Examples
To execute the tasks in the default target,
compile, type the following command from the
directory containing our sample build.xml file:
ant
Ant will open the default buildfile, which is
build.xml, and execute that
buildfile’s default target (which in our case is
compile). You should see the following output,
assuming your directory is called antbook:
Buildfile: build.xml
prepare:
[mkdir] Created dir: C:\antbook\build
[mkdir] Created dir: C:\antbook\build\classes
[mkdir] Created dir: C:\antbook\build\lib
compile:
[javac] Compiling 3 source files to C:\antbook\build\classes
BUILD SUCCESSFUL
Total time: 5 secondsAs Ant runs, it displays the name of each target executed. As our
example output shows, Ant executes prepare
followed by compile. This is because
compile is the default target, which has a
dependency on the prepare target. Ant prints the
name of each task within brackets, along with other messages unique
to each task.
Tip
In our sample output, [javac] is the name of the Ant task, not necessarily the name of the Java compiler. If you are using IBM’s Jikes, for instance, [javac] is still displayed because that is the Ant task that is running Jikes behind the scenes.
When you invoke Ant without specifying a
buildfile name, Ant searches for a file named
build.xml in the current working directory. You ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access