Meera has posted 70 posts at DZone. You can read more from them at their website. View Full User Profile

Ant in Action

02.25.2008
| 3482 views |
  • submit to reddit
Published by: Manning
ISBN: 193239480X

Reviewer Ratings

Relevance:
5

Readability:
5

Overall:
5

Buy it now

One Minute Bottom Line

I have been using Ant for several years, and I must say I learned a lot more by reading this book. I will certainly be able to write custom tasks and test them using AntUnit, which I have not done before. Anyone writing any kind of Java application definitely needs this book on his or her bookshelf.

If you are using Ant or planning to use Ant, this second edition of Manning's bestseller is worth every dollar. A must-have book for every Java developer.

I can report with confidence that I have graduated from intermediate to expert level after reading this book and working the examples.

Review

Ant in Action is divided into three parts. Part 1 introduces the fundamentals of Ant and shows how to use it to build, test, package, and deliver a Java library. Part 2 takes what you learnt in Part 1 further, and explores how to use Ant to solve specific problems, like coordinating a multi-project build, and deploying and testing web and Enterprise applications. Part 3 which will be very useful for experienced Ant users, is a detailed guide on how to extend Ant in scripting languages and Java code.

Part 1

Chapter 1 Learning Ant provides a simple introduction to what Ant is, what it is not, and what makes Ant the best build tool for building Java projects.

Chapter 2 A first Ant build dives into Ant's syntax and mechanics. It starts with a simple project to compile a single Java file and evolves it into an Ant build process, which compiles, packages, and executes a Java application.

Chapter 3 Understanding Ant datatypes and properties. In this chapter the authors introduce you to Ant's foundational concepts of paths, filesets, properties and so on. This is an important chapter for understanding what makes Ant such a remarkable build tool.

Chapter 4 Testing with JUnit. Testing is key to any software project and Ant and testing go together. This chapter introduces JUnit, this is the chapter which will introduce you to the program that will be developed in this book; a diary application. You will also learn how to integrate the tests into the build process so that Ant compiles both the source as well as the tests, run the tests and finally generate HTML reports.

Chapter 5 Packaging projects. In the previous chapter you learned how to compile and test the diary application, this chapter covers distribution packaging from Zip to tar. In the final sections the authors cover some new concepts introduced in Ant 1.7 like resource and resource collection model of Ant.

Chapter 6 Executing programs explores running programs under Ant using the three tasks, <java>, <exec>, and <apply>.

Chapter 7 Distributing our application. As the name suggests, the authors show us how to distribute our diary application according to the following activities:

  • FTP-based distribution
  • Email-based distribution
  • Secure distribution with SSH and SCP
  • HTTP publishing of the artifacts
  • Distribution over multiple channels.

Chapter 8 Putting it all together presents a single build file that will incorporate everything you learned in the previous chapters like: Ant's tasks, targets, properties, and how to compile, test, package and distribute. The last few sections also discuss the issues involved in migrating to Ant, adopting Ant and building an existing project under Ant.

Part 2

Chapter 9 Beyond Ant's core tasks explores the different kinds of tasks that Ant supports; built-in, optional and third-party. The authors show us the various SCM optional tasks, and later Ant-contrib and Checkstyle. In this chapter, the authors have used CVS as the SCM system.

Chapter 10 Working with big projects. If you are working on a large project, this is the chapter for you. The authors try to answer many of your questions like:

  • How do you build very large projects?
  • How do you manage library dependencies?
  • How do you manage the many build files you end up with?

Chapter 11 Managing dependencies. This chapter was completely new to me and so was Ivy. To quote from Ivy's website: Ivy is a tool for managing (recording, tracking, resolving and reporting) project dependencies. It has a lot of powerful Features, its flexibility, integration with ant, and its strong transitive dependencies management engine.

In this chapter, the authors start by introducing Ivy, installing Ivy and configuring the same. In the next few sections, you'll see resolving, reporting and retrieving project dependencies. The final section covers working across projects with Ivy, managing file versions through Ivy variables, excluding unwanted repositories and finally moving to Ivy.

Chapter 12 Developing for the Web covers how to develop a web application, build the WAR file, deploy and finally testing the web application using HttpUnit.

Chapter 13 Working with XML. If you have worked on any Enterprise projects, you have definitely worked with XML. This chapter explores XML processing in Ant. You'll see some basic ways that Ant can work with XML, and also how to use Ant to validate the Atom feed of events coming off the diary application, and to generate Java source files from XML templates.

Chapter 14 Enterprise Java. You'll see how to make entity and session bean classes by simply annotating the source, building the ear file. Later, you'll deploy this application to JBoss application server. Finally, the most important aspect of any enterprise application is to test your application, and this is covered with Apache Cactus.

Chapter 15 Continuous integration. The book until now covered every aspect of building an enterprise application with Ant, in this chapter you get to know how to delegate all the work which was done manually to a machine.

This chapter uses Luntbuild, which is a web application that can be set up to rerun Ant builds on a daily, nightly or hourly basis. If you're not using Luntbuild and use Cruise Control or some other Continuous Integration tool, feel free to skip this chapter. If you want to learn more about Continuous Integration, here is a book review which provides you with more details. Read it here.

Chapter 16 Deployment. We built a complete Enterprise application until now, but we also need to deploy this application all the way to production, right? This chapter explores Ant's built-in deployment support, database setup. The authors also show us how Ant can delegate advanced deployment to another tool, called SmartFrog.

Part 3

Chapter 17 Writing Ant tasks. This chapter with several examples will provide you all the necessary information you need to write custom Ant tasks. Up until now, we tested Java classes using JUnit, web applications using HttpUnit, EJB applications using Cactus, in this chapter you'll see how to use AntUnit to test your Ant tasks.

Chapter 18 Extending Ant further. Yet another interesting chapter which completely blew me away, in which we get to see other ways that Ant can be extended. Some of those are:

  • Writing tasks using scripting languages with the <script> and <script-def> tasks.
  • Writing new conditions for use in <condition>, <fail>, and other tasks.
  • Writing custom resources, filters, selectors and mappers
  • Monitoring the build process with custom build listeners and loggers
  • Embedding Any inside your own program

Published at DZone with permission of its author, Meera Subbarao.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)