Ant: The Definitive Guide
Compilation of all Java™ source files is no longer the only step necessary to build many
Java-based projects. For the typical HelloWorld program, book examples, and simple applets,
source file compilation is sufficient. Complex Java-based projects, like web applications or
Swing-based programs (such as JBuilder), require much more. Up-to-date sources must be
retrieved from source control. Dependencies not automatically handled by the Java compiler
need to be managed. Various classes must be bundled and delivered to multiple locations,
sometimes as JAR or WAR files. Some Java technologies, such as Enterprise Java Beans
(EJB) and Remote Method Invocation (RMI) classes, need separate compilation and code
generation steps not performed by the Java compiler. While shell scripts and GNU Make are
often the first choice tools for performing these alternative tasks — in terms of "getting
the job done," these tools perform adequately — they turn out to be poor choices in the long
run.
As functional as it may be, GNU Make leaves a lot to be desired in terms of ease-of-use.
Makefiles have their own language syntax, requiring a separate knowledge set for their
authors. GNU Make lacks platform-independence, requiring multiple versions of the same
makefile (one for each target platform) to be maintained and distributed. The nature of shell
scripts and GNU Make (remembering that GNU Make is simply a language extension on top
of an existing shell) makes moving from operating system to operating system, and even from
shell to shell, difficult or impossible for anyone but an expert user. While it is not unusual to
use GNU Make, the time and maintenance required to follow this path is too high for modern
Java-based projects.
Sun provides Java versions of all their SDK tools. Executables such as javac are simply
wrappers executing the Java code. Other vendors' tools, like BEA's EJB compiler for
WebLogic, JUnit, and the Jakarta tools and libraries are all written in Java. GNU Make can
only call executables from the command line. For example, to invoke a Java class, GNU
Make must use the java command to invoke the JVM, and pass the class name as a commandline
argument. Make is incapable of programmatically using any of the Java tools' libraries,
such as exception and error objects. These libraries allow for a more flexible build process. A
tool written in Java (such as WebLogic's ejbc compiler) can share information from
exceptions and errors with other objects (such as Ant task objects) available inside the same
JVM. This serves to enhance the build process beyond command-line return codes and afterthe-
fact error-message string parsing.
The problems with GNU Make and the possibilities of a build tool written in Java influenced
James Duncan Davidson to write Ant. Ant runs the Java compiler as a class, not as a call from
the command line. Remaining inside the JVM allows for specialized code to handle errors,
and for action on results Sun provides through its compiler. Ant uses XML as its buildfile
syntax, therefore enhancing, rather than straining, developers' and project managers' skill sets.
Ant extends the build process beyond just running programs, and is more properly termed a
build environment than a build tool.
This Book is Available HERE
Don't Forget to say Thanks
No comments:
Post a Comment