Java Development with Ant
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.
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?
I don't know about you guys, but all the fine Java ladies dig my JUnit.
-gerbik
I tried to get the little guys to write some jsp for me, but they wouldnt go onto the keyboard without me spreading honey on it.
It's good that there's a book on how to get them to do what you want.
Be you Admins? nay, we are but lusers!
Is that they made up the syntax as they went along - there's little consistancy. It's a mess of different tags even for similar tags. And I think XML sucks for the purposes of build processes. It's hard to read and a pain in the ass to type.
... the Java equivalent of make and makefiles. (...for those that don't know. They really didn't give a capsule explanation in the review) I personally like to develop java from the commandline, and Ant's conditional compilation (only compiling files that have changes) saves tons of time. Not to mention that it is quite useful in rolling out and configuring products. Even if you use an ide like Forte, it would probably be a good idea and head to the Ant page and see what is all about.
Also, it has become somewhat of the defacto standard in open source Java development.
Why, o why must the sky fall when I've learned to fly?
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.
where can anyone find a decent cup of cofe flaovored cofe without bugs?
I've always used makefiles for my Java development and it works very, very well. Make is a proven product, has a well-defined, well-documented syntax and for the most part, is very easy to read (while Ant's XML mishmash is a mess).
>>The book is divided into beginner, intermediate and advanced sections, which makes it appropriate for a variety of audiences.
It sounds to me like it's equally UNappropriate for all audiences. If I'm a beginner, I want a whole book for me, same with intermediate of expert. There are exceptions to every rule, but that model sounds better than I think it will work.
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.
Amazon link
Just trying to save people some cash.
FYI if you don't want to buy b/c the patent issue I have to disagree. If patents are legal there is nothing wrong with following the law. If you don't like the law get off your rear and try to get it changed. (Me i'm too lazy, so I'm trying to inflame you into action!)
Autoconf can do detailed dependency checks, e.g. whether the int is 2 bytes or 4 bytes, or if the compiler can handle some things. When building projects with ant, lot of things may be more difficult to handle (e.g., a situation where we may not have a library for XML parsing), we will get a compiler error rather than a dependency check error.
Ant is a part replacement for make, but developing with ant comes no where near autoconf + make combination.
S
Ant a positive example of where the true goals of open source have succeeded. By offering a simple framework to extend build tasks, many other open-source development tools have been able to easily plugin to the Ant framework. It is in a word a community success.
On another note, I always find it interesting that a book is published on Ant while it is probably the best documented project underneath the Jakarta umbrella.
....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
The Army reading list
I found Tomcat book from Wrox more than useful. Definitely Ant is powerful, but I dont need more.
I've found ant to be a fantastic tool. I used to use make files, but I started using ant for quickly testing and then deploying builds on different platforms. It can be used for all types of programs, not just java, so it's great for managing cross platform development in a standard way rather than having different build processes on different platforms.
With make files, I can keep everything in one directory (I dislike having a src directory). With make files I can run ispell (I don't know of a spell checker I can use with Ant.) With make files, I can upload to my web site using scp (Is there a Java scp?)
You might want to switch to Ant to make building on different platforms easier. My make files work on Linux, Mac OSX, and Windows with Cygwin, so I don't feel too limited.
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.
.tar.gz treatment, sent to the appropriate server by FTP, where it is later extracted through a remote console. All of this is done in Ant.
This is doable. Well - nearly, anyway. My team uses Ant to build and deploy our Enterprise applications. Essentially, we have Ant build our sources nightly. If everything goes ok, the whole deployment tree gets the
If there is a failure, I get a notification in my mailbox that gives me the Ant output. The server didn't get any updated files, so nothing changed. Simple.
Using Ant, we've been able to work with CVS fairly easily, and other built-in and third-party addons help a great deal. No, it's not make, but for our application which has ~1000 java classes and another ~1000 data and properties files, it just works.
You can accomplish anything you set your mind to. The impossible just takes a little longer.
wait until you work with XML.
Not only is the dreaded "tag" problem much worse, but you have the dreaded problem, the terrifying missing / problem , and the abominal " your attributes andand escape your entities problems.
most text editors can effectively combat the tab problem these days, but hand edited xml files (especially when they get to be over a thousand lines long) are a nightmare.
Our company is doing a mixture of Java and C++ so we are using make. I came across a fantastic conditional compiler written by some developer at sun.. JavaMake It can be easily integrated with Ant and it evaluates the bytecode of the updated files to see what signatures have changed. It then recompiles anything using those signatures if they weren't changed as well. It works *wonderfully*. The only limitation is compile time constants. If you change the name or type of a constant, it has to recompile the whole project because the Java bytecode only has the substituted value, not a reference to the variable.
Check it out. It can save a *lot* of time.
All I wanted was a rock to wind a piece of string around, and I ended up with the biggest ball of twine in Minnesota
I'm about halfway though the book, and so far I think it is excellent. I've been reading it bit by bit over school and other projects. It's extremely readable, seems more informative than a 200-300 page O'Reilly book (which are great for intros, but this goes into a little more detail), and includes good coverage of JUnit testing and how it is integrated into ant.
I had a chance to meet Steve Loughran at Web Services DevCon East, and he's awesome. His website, including a great paper called When Web Services go Bad. He also has a SOAP development blog.
6.02x10^23, baby!
It's an open-source project called NAnt
I completely rewrote my previous company's build system in Ant and Make. I used Make to do all the cross platform macro and definition setup and Ant to compile and jar the classes. The build performance gains were incredible. I would have used all Ant, but it just doesn't have the text manipulation functions that are built in to Make that I needed. Plus, a hybrid system of Ant and Make gives you time to transistion as much as you want to Ant on your own schedule instead of having to take a big bang approach to a new build system. Rocket Your humble buid servant.
Rocket Your humble build servant.
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
Unfortunately it's the same class that will make you blink out of existence, so you'll never see it.
Ant DTD. The link to the download is about halfway down the page. Took me almost 5 seconds with Google. =)
This post is free (as in cheese in a mousetrap).
However it became burdensome so they dropped it. In 1997-8 there was no better place to buy (no pun intended). Their service was spotty but overall if you had a problem and were consistant in your communications it would be resolved.
The way they formerly did it was you faxed them a copy of the receipt (at the time from any retailer) and they would beat it by 10% or pay the difference!!! Pretty cool (although not a good business decision in the age of PriceWatch and Shopper.com).
Why, really? Guess what, in the rest of the world we also develop Ant with Java!
So: import java.awt.*; import javax.swing.*; import java.stop.sucking.*; *poof* "We're going to need another loknor!"
me karma am bad
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.
Unless everybody in your team is going to be forced to use the same IDE, you need another solution. IDEA is great from what I've seen of it, but in our team of five developers we use five different IDEs/editors with everything tied together with Ant and CVS.
Suck figs.
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!!!!!!!!!!!!!!!!
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).
Shut the fuck up you pompous ass.
Ant is not worth fixing.
You must edit Ant's XML by hand.
How long have you been a moron?
Sorry for screaming, but I hadn't seen that mentioned yet, and it's day two.
Perhaps it's possible to write ant scripts that execute as efficiently as make, but it must not be very easy to do, since I have never seen one.
It's really nice when you're in a compile/edit cycle if it takes only a few seconds for your compile to build you a new version of your system. If it takes a minute you'll be walking around the room getting a coffee, talking to your co-worker, and totally losing your train of thought.
Most make systems I've seen compile java code a zillion times faster than ant. Sure, ant can look deeper into the java files and compile just the classes it has to, whereas with make you frequently have to compile everything. But here's the trouble: make has already finished compiling everything before Ant has even parsed all of its XML.
I really would like to use Ant. It feels like it's the right thing to do. But I can't afford it, my time is too valuable, and it's too damn slow.
Also I find complex Ant scripts FAR more difficult to understand than complex make scripts. Sure for simple build scripts the "tab and space" thing may be an issue--but for less trivial applications these issues wash away and you start wondering where bits of information came from and with Ant you sometimes just don't know.
I've seen Ant scripts break in ways that were not obvious to anybody, and took hours to debug. I've never had such trouble with make unless I was trying to do something brutally stupid with it.
Maybe I'm wrong about all this. I sure hope so, because I would like to have a good Java centric tool. My main concern is that Ant sucks, and yet it's established enough market share that it's locking out further innovation in the area.
I really think Ant blows.
..i work with ant some time now, but this book thought me lot i haven't known before!! If you are interested in ANT & Co buy this book and be happy :))
-- Outside a dog a book is mans best friend; and inside a dog its too dark to read..