Ant - The Definitive Guide
As a long time Ant user, I have written many Ant build scripts, automating my builds and speeding up the overall development cycle, mostly relying on its excellent online documentation. As a Java developer, I have admired its simple and intuitive interface and the modular design. So on getting Ant: The Definitive Guide in my hands I wasn't expecting a whole lot new to learn, and thought of using it only as a reference book.
After having the book on my desk for more than a month, though, and occasionally flipping through its pages whenever I would otherwise have consulted the online documentation, I must say that I had been missing out on some very important things: tasks like ftp and war deployment that I was simply not aware of and had never felt the need to look up, but could very well use. The other interesting thing I noticed was that my build scripts became smaller, more modular and easier to read.
Like most books in the The Definitive Guide series, Ant The Definitive Guide assumes a certain level of familiarity with underlying technologies such as Java and XML and focuses on providing complete, reference like details of Ant features and tasks. These description are generously supplemented with examples and code fragments.
But so is the the online documentation for Ant! Will someone gain additional insight in using Ant, or be able to work faster, or make better use of Ant capabilities, by consulting this book, instead of the online documentation for a particular Ant task? To find the answer, I randomly picked two topics -- filesets, an important and oft-used Ant datatype, and javac, a core Ant task -- and compared their online description with the one in the book. Here is what I found.
Besides the datatype definition, explanation of various attributes, sub-elements, and the examples, the book also covers how to specify conditional inclusion or exclusion of certain filename patterns when a property is set (or unset). Though this can be inferred from online documentation by a determined user, this particular use is far from obvious. The coverage in the book also talks about the relationship of the fileset datatype with the javac task, pointing out that the fileset attribute dir is equivalent of javac attribute srcdir, as attribute dir will be confusing in javac: is it referring to source directory or destination directory. This is the kind of insight that really helps a user.
The treatment of the javac task in the book is not much different from the one in the online documentation. Both have almost the same material, though the information in the book is better organized for new users. On the other hand, I found the online documentation to be more complete, especially with respect to the compiler specific options and behavior idiosyncrasies.
Here is a rundown on what the book covers: Chapter 1, Getting Started is a quick primer on Ant, with sufficient details for a new user to start using Ant for very simple build tasks. Chapter 2, Using Properties and Types introduces the building block tasks and datatypes, such as property, condition, fileset, path like structures, selectors and so on, used in other Ant tasks. Chapter 3, Building Java Code covers the tasks and activities around compiling Java source files (ie; javac), organizing the build steps in various targets within a single build scripts and/or across multiple scripts, generating documentation using javadoc and creating distribution jars and zip files. The rest of the chapters are devoted to tasks for specific purposes, such as launching external programs (Chapter 7, Executing External Programs), copying files and manipulating directories either on the same machine or over the network (Chapter 4, Deploying Builds), running JUnit tests (Chapter 5, Testing Builds with JUnit) and so on. There are also separate chapters covering interaction of Ant with XML and XDoclet (Chapter 9, XML and XDoclet) and with Eclipse (Chapter 11, Integrating Ant with Eclipse). The last chapter, Chapter 12, Extending Ant, talks about extending Ant by doing things like adding your own tasks, creating custom filters, writing your own build listeners and loggers etc. This chapter also has a small section on how to embed a script written in one of the supported scripting languages within an Ant script.
As you can see from this outline, the book covers almost everything that is to know about Ant and other related software.
So, what is not so good about this book? Well, I didn't find anything wrong with the topics which are actually covered by the book. Of course, there are additional things that I would have liked to see in the book: (a) A good sample Ant script which could be used as the starting point for most small to medium-sized projects; (b) A more thorough explanation of how dependencies among targets determine the execution sequence and how this fits in with explicit invocation of targets; and (c) pictures to illustrate some of the concepts such as life cycle of an Ant task, selection of files in a fileset and the dependency tree of targets.
Overall, I found the book to be comprehensive, well organized, easy to read and good value for money.
You can purchase Ant: The Definitive Guide from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
I have a web service application that resides as a seperate module in CVS. I needed the ability to build a JAR, and move it either to local qa application servers, or a remote server.
I thought I'd try Maven. After spending 4 hours looking for and reading what passes for documentation on the Apache site, I gave up, and wrote a batch script to do it in 15 minutes.
The Apache docs suck for many of their projects (Tomcat, Maven, Axis). Do the developers do it on purpose so that they can make money writing books explaining the tools? I have no idea.
To be fair, some Apache documentation is good (in the commons projects, like CLI and HttpClient).
Is there anything out there that is (a) easily deployable (nothing turns off a prospective user than being told to download and install a complicated build system that depends on $LANGUAGE_OF_THE_MOMENT), (b) suitably flexible that I can customise it to work with all my little build tools, and (c) sufficiently elegant that I won't want to vomit looking at my build scripts six months later?
So far, the only thing I've found that works at all is traditional make. Which, I'm afraid, sucks. Makefiles scale very badly (recursive make. Eeeaah), don't handle disparate rulesets well (I want to build these C files with this rule and these with this other rule... oh, wait, I can't), and the dependency handling is practically nonexistent (you can fake to a certain extent with .d files, but that all falls apart as soon as you need to depend on dynamically made files).
A case in point: I maintain the ACK, a portable compiler toolchain that's about 20 years old. The build system is an intricate network is shell scripts and recursive makefiles. It works, but it's largely incomprehensible, very slow, doesn't handle incremental rebuilds, and is going to be a maintenance nightmare should we ever need to do any major revamps. I'd love to replace it; I've gone out actively looking for something better --- and I've failed.
Any suggestions?
This has been a public service rant by a stressed build technician.
Hey, make fiends, try this: add new functionality to make, extending its syntax. PITA, you say. It's very simple with ant.
Can someone explain to me the difference between Ant and Maven? I have noticed almost everyone supports Ant, but there are people who also do Maven. Are there any advantages, disadvantages, are the different but overlap greatly, and why does Apache support what appears to me to be two competitive technologies...
Very confusing to someone who just has a high-level understanding of Apache world.
D.O.U.O.S.V.A.V.V.M.
There is a port of Ant to .NET available from here.
It had a great following until MS announced MSBuild.
Unfortunetly, MS put RIP on it when they created MSBuild, which comes with .NET. Visual Studio project files are MSBuild files.
The answer is that all of these groups and people created a XSLT - a functional XML programming language. That's right, the people who produce the XML spec also produced an XML programming language, just like Ant.
XML is a meta-markup language, a series of rules, and you can represent data files as much as you can represent programming languages because they're all text files. You may as well say MAKE scripts are also a misuse of technology, being ASCII, if you're going to claim that ASCII should only be used for configuration files.
With constructs that can be compiled who's to say XML can't be a programming language? The W3C say that depending on the domain it can be, and they disagree with you.
-Docvert converts MSWord to OpenDocument, clean HTML
Good stuff...