Java Reference
In-Depth Information
MAKE VERSUS JAVA BUILD TOOLS
make is the original build tool from the 1970s, used in Unix and C/C++ development. make and
the Java-based tools each have advantages; I'll try to compare them without too much bias.
The Java build tools work the same on all platforms, as much as possible. make is rather platform-
dependent; there is GNU make , BSD make , Xcode make , Visual Studio make , and several others,
each with slightly different syntax.
That said, there are many Java build tools to choose from, including:
▪ Apache Ant
▪ Apache Maven
▪ Gradle
▪ Apache Buildr
Makefiles and Buildr/Gradle build files are the shortest. Make just lets you list the commands
you want run and their dependencies. Buildr and Gradle each have their own language (based
on Ruby and Groovy, respectively), instead of using XML, so can be a lot more terse. Maven uses
XML, but with a lot of sensible defaults and a standard, default workflow. Ant also uses XML,
but makes you specify each task you want performed.
make runs faster for single tasks; it's written in C. However, the Java tools can run many Java
tasks in a single JVM—such as the built-in Java compiler, jar/war/tar/zip files, and many
more—to the extent that it may be more efficient to run several Java compilations in one JVM
process than to run the same compilations using make . In other words, once the JVM that is run-
ning Ant/Maven/Gradle itself is up and running, it doesn't take long at all to run the Java com-
piler and run the compiled class. This is Java as it was meant to be!
Java build tool files can do more for you. The javac task in Ant, for example, automatically finds
all the *.java files in subdirectories. Maven's built-in compile goal does this too, and knows to
look in the “src” folder by default. With make , you have to spell such things out.
Ant has special knowledge of CLASSPATH, making it easy to set a CLASSPATH in various ways
for compile time. See the CLASSPATH setting in Example 1-1 . You may have to duplicate this in
other ways—shell scripts or batch files—for using make or for manually running or testing your
application.
Maven and Gradle take Ant one step further, and handle dependency management. You simply
list the API and version that you want, and the tool finds it, downloads it, and adds it to your
classpath at the right time—all without writing any rules.
Search WWH ::




Custom Search