Slashdot Mirror


Java Development with Ant

smarks writes "Java Development with Ant effectively shows the reader how Ant can be used as the foundation for the most complex Java software configuration solutions. The book is divided into beginner, intermediate and advanced sections, which makes it appropriate for a variety of audiences. The book has a comprehensive survey of tools that can be used with Ant such as JUnit, CheckStyle, Middlegen and XDoclet Even the experienced Ant user will find these sections helpful. Overall, Java Development with Ant is an excellent resource." Read on for the rest of Spencer's review. Java Development with Ant author Eric Hatcher, Steve Loughran pages 634 publisher Manning rating 8.5 reviewer Spencer Marks ISBN 1930110588 summary How to use Ant to meet all (or most of) your poject's software configuration needs

Pros:

  • Excellent coverage of optional Ant tasks
  • Good division of beginner, intermediate and advanced content
  • Thorough discussion of how to use Ant to solve a variety of software configuration management situations
  • Shows how to use Ant for tasks outside of typical configuration management roles such as the automated code generation of EJB and Application Server deployment descriptors
  • Shows how Ant helps with a variety of software development methodologies including XP's suggested best practices of continual integration and JUnit testing
  • Catalogs IDEs that integrate well with Ant including my personal favorite, Intellij's IDEA development environment

Cons:

  • Some of the examples could have benefited from more detail. For example, the section on the PropertyFile task could have shown how to solve the problem of platform specific path separators in Java property files.
  • At the time of this review, the book's accompanying website was a bit meager. For example, a comprehensive list of Ant on-line resources would have been helpful.

What the book offers

I consider myself an intermediate Ant user and when books on Ant first appeared I thought they would add little to the excellent free documentation and examples readily available. With its clean, straight forward syntax and structure, Ant has a low of cost of entry, and being rooted in Java and XML it is extremely flexible and extensible. I found Ant refreshingly easy to use as part of a configuration management system that included continual integration and a unit testing strategy. It was much better suited for Java development than the tool I previously used which was make. So when I agreed to do this review, I was skeptical that I would find the book useful. However, the book proved to be rich in valuable information that is well organized and clearly presented. Java Development with Ant, written by Erik Hatcher and Steve Loughran who are both committers to the Apache Ant project, is a great resource for anyone wishing to learn how to integrate Ant into his personal set of best practices for software configuration management solutions.

Coming to the book as a long time Ant user, I was glad to see that it offered material appropriate for others than just those approaching Ant for the first time. The book is divided into three sections each of which could probably find a niche as useful (and thinner) separate book: Learning Ant, Apply Ant, and Extending Ant. Only the first section of the book is devoted to first-time users, or those Learning Ant. The reminder of the book is about Ant in action. It covers an interesting variety of third-party Ant tasks, various ways of applying Ant to software development projects, and an in-depth section on how to extend Ant writing your own Java classes.

After a short but helpful introduction to the general topic of software configuration management, the first section, Learning Ant, launches into a thorough explanation of Ant's fundamental concepts and operation. JUnit test integration is treated as part of of the basic operation of Ant, which I was happy to see because unit testing should be a fundamental part of any software configuration management process.

Despite having used Ant on a number of projects since the summer 2000, at no point have I had to become truly expert with it in order to solve the wide range of software configuration problems I encountered. This is because Ant is easy to use. Typically, I figure out what I want the software configuration management to do, and then look for Ant examples that I can easily tweak to get the job done. I think it is a great credit to the Ant and its designers that I can do this successfully. Even though I've had this success with Ant, the introductory material filled in some of the gaps I had in my understanding of Ant's operation. For example, I was introduced to the PropertyFile taskdef which up until then had escaped my notice but which solved a problem for which I previously had a less elegant solution.

The most interesting part of the book was the second section that talked about a variety of Ant add on programs (called taskdefs) like Middlegen (an EJB descriptor tool) and XDoclet. XDoclet had been on the periphery of my radar for a while now, so I welcomed the book's thorough discussion of it in both a general and Ant specific sense. In addition there are helpful chapters devoted to using Ant as an aide to production deployment, web site generation including the compilation of JSP pages and the automatic generation of EJB descriptors. There are also chapters on working with Web Services using SOAP and a section on how Ant can be used as part of a continuous integration process complete with email notification. There is even a section on using Ant for Java projects that have a native code component. (Ant can be used to compile native code and the book shows how it can be helpful in dealing with the complexities surrounding JNI.) The book works well as a reference text. There's no need to read it from cover to cover in order for it to be extremely helpful.

The third part of the book also looks interesting, but it is intended for a more hardcore audience than myself. I've been fortunate to find ready made solutions for all the configuration management services I wanted to provide my clients. So, learning how to extend Ant has never been an issue. Every time I think I might have to develop my own answer, I find that someone else has already beaten me to it. Such is the nature of successful Open Source projects. However, I am glad this section exists, because I am sure at some point I will use it myself or refer a student or client to it.

The book even has some material on using Ant outside of the context of Java. Not having much experience with these technologies, I didn't pay close attention to these sections. (I am sure I'll be amused when I encounter my first .NET project that is using Ant for its configuration management solution).

In closing, if you are more than casually interested in software configuration management for Java projects then I recommend this book with enthusiasm. Beginners will be up and running with Ant in short order, while the book contains many interesting and useful nuggets for more experienced Ant users.

Ant on the web

  • The Ant Project -- be sure to see their resources section.
  • Ant FAQ at jguru.com (moderated by the book's co-author: Erik Hatcher)
  • Ant forum at jguru (moderated by the book's co-author: Erik Hatcher)
  • JUnit: A regression testing framework written by Erich Gamma and Kent Beck. It is used to implement unit tests in Java.
  • CheckStyle: A development tool to help programmers write Java code that adheres to a coding standard.
  • Middlegen:A general-purpose database-driven code generation engine.
  • XDoclet: An extended Javadoc Doclet engine. It's a generic Java tool that lets you create custom Javadoc @tags and based on those @tags generate source code or other files (such as xml-ish deployment descriptors) using a template engine it provides.
  • Intellij's IDEA "Develop with Pleasure" with this award winning Java IDE featuring full Ant integration that Marin Flower says: has succeeded in really moving forward the state of the art...
  • The NetBeans and Eclipse Open Source IDEs also integrate nicely with Ant.

You can purchase Java Development with Ant from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

11 of 171 comments (clear)

  1. Use campusi.com by Anonymous Coward · · Score: 1, Interesting

    Use campusi.com, type in the ISBN number (1930110588), and you'll see that half.com and alldirect.com have it for $29.72 and $31.32. Every buck counts these days, you know!

    and FP?

  2. Ant sucks by Trinition · · Score: 3, Interesting

    Ant sucks. But its the least sucky option. The syntax is very inconsistent, and there's a lot of things you can't do easily (i.e. control flow). But for 90% of a build process, Ant will do what you need out of the box. Everything else you have to cusotmize, build custom, or just skip Ant altogether.

    Still, I have high hopes for the next big version of Ant where they plan to fix a lot of these problems.

  3. Re:biggest complaint about Ant by GusherJizmac · · Score: 5, Interesting
    Yes, ant is really not much (and at times worse) than make for figuring out dependencies, and it seems unlikely to change, due to ant's structure. The XML is really an completely inappropriate use of it, and makes build files hard to work with and understand.

    Ant is basically a cross-platform scripting language that is really really weak. Really weak. I'm much looking forward to AAP by the programming god Bram Moolenar. This system is the logical extension of make into the 21st century.

    --
    http://www.naildrivin5.com/davec
  4. Ant is not what I wanted... by MSBob · · Score: 4, Interesting
    out of a build/deploy tool. One thing I always envisioned in a build/deploy script is the ability to successfully 'rollback' all the changes applied in case of a failure. Say I tried to move a bunch of files from directory A to B and if one of them lacks write permissions it moves none of the files. This would help us come a long way towards a robust build and deployment strategy. Most install scripts are not only pretty poorly written (expect certain files to reside in specific locations) also in case of failure they leave an inconsistent mess of random files moved or copied around on your drive. We need a build/deploy tool with 'rollback'.

    Also, there is little consistency in Ant's syntax. Are they planning on creating a schema or a DTD for Ant so I don't have to perpetually debug my scripts by trial and error? What about a debugger? Ant's getting more and more complex as a scripting engine and it's approaching the point where a debugger would really be useful in some cases.

    --
    Your pizza just the way you ought to have it.
  5. Ant rocks, but watch out for chmod +x... by tcopeland · · Score: 1, Interesting

    ....I mean, if you use the Ant zip task to bundle up some files, you'll lose any execute permissions that you had on those files.

    So if you do an automated deployment of an app that includes some scripts, you'll need to chmod them again before they'll work.

    Other than that, Ant rules.

    tom

  6. Re:The book is divided by iplayfast · · Score: 3, Interesting

    presumably after reading through the beginner section, you will no longer be a beginner, and are ready for the interediate section.

  7. Who needs tools like Ant and Make by OmniVector · · Score: 3, Interesting

    When you have intelligent IDEs like IntelliJ's IDEA. I understand what a make file is from my c++ programming, and if that's essentially what Ant does, I have no use for it. IDEA automatically only compiles the files I've changed, or if i want, rebuilds everything. Not to mention it obviously recurses into every directory in my project and compiles everything. So in light of all that, why would Ant prove of any use to me if i don't use command line java writing tools?

    --
    - tristan
  8. Can you sell ant to a make user? by Simon+Brooke · · Score: 3, Interesting
    I've been writing exclusively in Java for seven years now. I've tried ant a couple of times and found it so balky and counterintuitive that I didn't bother persuing it. Yes, my Makefiles only work on Linux, but then I only build things on Linux. If anyone else wants to build my stuff on other platforms that is their problem. They can run them just fine on other platforms - that's the joy of Java.
    • What problems does ant solve for me that make doesn't do much easier?
    • How can I migrate my (considerable) investment in makefiles to ant and why should I bother?

    These are the questions I need someone (or some book) to answer. Will this book answer them?

    --
    I'm old enough to remember when discussions on Slashdot were well informed.
  9. Great book, great XML editor by kelzer · · Score: 3, Interesting

    I bought the book, and that's saying a lot because I'm very cheap. It's a great book that doesn't just teach you how to use Ant, it teaches you how to do lots of things with Ant, like build web services using the excellent Apache Axis, which can automatically create a web service from any Java class source file. It also teaches you how to use JUnit to do automated unit testing with Ant, how to use CruiseControl, etc., etc.

    A lot of posters have complained that XML isn't very human-readable. I use and highly recommend a great little tool called Pollo. It has built in support for creating Ant build.xml files, as well as Cocoon sitemap files, XML schemas, etc. IMHO, it's got the best XML editing GUI I've found.

    --

    ---------------------------------------------
    SERENITY NOW!!!!!!!!!!!!!!!!
  10. Re:The book is divided by steve_l · · Score: 3, Interesting


    You can skip the first eight chapters then :)

    You still might want to look at some of the advanced subjects, such as how to compile jni native code using , then run junit tests against it, how to set up cruise control or the gump to rebuild your code hourly, how to build C# clients to interop test your web service, etc.

    If we'd stopped at the first section and added a rewritten task reference you'd be making a valid point. But we wrote the book as a supplement to the docs. After all, our hand is in the docs too, from Ant in anger or Ant Task guidelines (both mine), to all the little corrections we made to the ant docs when we wrote the book and disovered errors.

    So use the docs -I think they are really good compared to many other OSS projects, and I am glad you like them. But I think you should still find value in Java Development with Ant. Erik and I really pushed the envelope in section two, doing stuff nobody had done in ant before.

  11. Ant is multi-faceted by redshift-systems · · Score: 2, Interesting

    I think an interesting point is that you are not restricted to compiling / configuring / running only your Java code with ANT. As an example I use ant to package and upload my PHP code to the web server, so its simply adding a tool feature on the IDE (editplus in my case) and clicking a button to set it off. So Ant can be a nifty tool in your toolkit.

    I'm sure that with a clever extension one could write ant modules that compile other languages as well (and Im sure it's already been done).