13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

216Chapter 9Ant: An Introducti<strong>on</strong>9.2THE NEED FOR A DIFFERENT BUILD TOOLJames Duncan Davids<strong>on</strong> had a problem. Perhaps you’ve had this problem, too.It has to do with the building of software—compiling, copying, and otherwisemodifying files to get all the pieces in all the right places for running a collecti<strong>on</strong>of programs.There are a number of ways to automate the building of software. You canscript the compilati<strong>on</strong> using shell scripts or batch jobs. That works fine, butthere are two problems with that soluti<strong>on</strong>. First, scripts are generally notportable across very different operating systems. That’s a serious problem for alanguage like Java, which is intended to be portable across operating systems.Sec<strong>on</strong>d, it is difficult if not impossible, using scripting languages, to preventwasted compiles; the checking and comparing of date stamps <strong>on</strong> source andobject files makes scripts large and difficult to maintain.Very well, we hear you say. There’s make. The make program has beenaround for a l<strong>on</strong>g time. It is available <strong>on</strong> many operating systems. It handlesthe c<strong>on</strong>diti<strong>on</strong>al compilati<strong>on</strong> of files very well. It has been around for centuries(it seems). It is well known and widely used. All of this is true, but even thisvenerable tool falls a bit short in the Java world. First of all, although makefilesare generally far more portable than other scripts, there are still c<strong>on</strong>siderablevariati<strong>on</strong>s in details, and make does nothing to mask the differences in file,path, and disk designati<strong>on</strong>s that exist across operating systems. Moreover, bothmake and scripts suffer from a more basic problem. Although Java programscan execute reas<strong>on</strong>ably quickly, the overhead of starting a JVM and tearing itdown again is c<strong>on</strong>siderable. Since javac is written in Java, each time it is invokedto compile a source file (<strong>on</strong>e file at a time is the make way) this setupand teardown time cost is paid.But, we <strong>on</strong>ce more hear you protest, you can just use javac <strong>on</strong> the entireproject! Doesn’t it build everything that needs to be built? In the simplest case,yes, it does. But as so<strong>on</strong> as you share code between projects, or use RMI whichrequires executi<strong>on</strong> of the rmic compiler, or use EJBs, or link in native methods,then javac’s dependency resoluti<strong>on</strong> just will not work.Luckily, James Duncan Davids<strong>on</strong> had this problem. And luckily it reallybothered him. And even more luckily for us all, he decided to share his soluti<strong>on</strong>.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!