After reading Jim Crossley's blog "Hating Maven less than Ant" I did a little thinking and reminiscing . . . . . Ant is almost certainly no longer in the ascendant with Maven making more in-roads but I still see more Ant than Maven in industry.
I fell in love with Ant back in 2002 when I found I could very quickly and easily plug in other tools such as Checkstyle, PMD, JUnit etc. especially with the help of one of my favorite books "Java Development with Ant"
Let me also address a few points from Jim's blog
1) "XML, which should never be used as a programming language "
Ant is really a souped up version of "make" which was declarative in nature - so is XML - prescribing "what" to do, not "how". But for most folks, it's true, eventually we end up writing "how" stuff (procedural things) for the more complex things - but still XML is not too bad as most ant tasks should be pretty small / modular and reusable.
2) "Ant allows you to describe your build however you please, but you must effectively do it from scratch for each project"
That's not necessarily true, back in '03 I created a re-usable ant library for all the basic things you need to run (clean, compile, test, checkstyle, create reports, email files etc.) and it's configurable via a property file. Hey if you keep the same basic project folder structure (standardization is not a bad thing) then you could re-use it only changing one property - the name of the project since all paths were relative.
But yes, in general, Maven is apparently more easily re-usable. I haven't really used Maven enough to know - I tried in '04 to follow a Maven tutorial and found it so complex (compared to Ant) that it scared me off and I haven't been back. Now that I see the Maven 2 snippet in Jim's blog I think complexity just went up even further. Hopefully I'm wrong - more competition in this space isn't a bad thing.
Furthermore until Eclipse integration with Ant improved I didn't make the jump to Eclipse and stuck with my company's prescribed IDE (JBuilder / WSAD).
Anyway this is a note to say, I guess, that my love for Ant is still strong - it has made my life as a developer and architect easier for many years now and, although showing her age a little, it is still the "little engine that could". I contrast that with Eclipse - so many dependencies to resolve yourself - bugs preventing me from easily upgrading. A great tool and getting better but not without it's cost in time and effort configuring, recovering workspaces etc.
For those of you using Ant already I can't stress enough how useful the book "Java Development with Ant" has been and continues to be. For those not using Ant or Maven you really are missing out on some powerful tools? Are there any alternatives I should know about?
10 comments:
I agree with all of that. I still intend looking at Maven properly some day, but to date it has always looked rather fiddly and overly-constraining.
I've been extremely happy with Ant (combined with the ant-contrib library). It still does all I need, and I haven't even got around to taking advantage of the modularization facilities in the latest releases.
I actually do use a standard structure for all my projects, and have a single copy of a single Ant script that works for all of them. By default this figures out the project/build root based on relative path from a trivial script within each project that invokes it. Then all the variations between projects are based on e.g. lists given by text files within the project, and examination of the project's directory structure etc.
It sounds (and is!) complex, but has worked well for me and keeps all the Ant XML in one place with no duplication. One day I ought to replace this with something more sensible, but at the moment it works so well that I've no motivation to change it.
I also prefer using ANT above Maven. I can do whatever I want, I can automate any process. I'm not forced to jump through hoops.
I hope to do something with Rake and Raven (Ruby based) in the near future. Creating a DSL for building, and letting you switch between DSL and full blown language is a big step forwards.
I've been using Maven 1.X mostly for the past few years, through no choice of my own. Between Maven 1.X and Ant, I'd take Ant.
Maven 2.X looks more appealing to me than 1.X, but I haven't used it for more than experimentation, so I'll reserve judgement.
I have been using Maven 2 for about a year now and I have become a convert. This was not without growing
There is no reason to use Maven. I have used it extensively. It is pretty much a black box of garbage.
Now that you can embed any of a dozen scripting languages in an Ant script, there simply is no good reason to use Maven.
Ant is an incredibly well designed tool. Its critiques are usually baseless.
Regarding point 2, Ant lends itself to clone and modify development, but Maven is worse: instead of possibly wrong but obvious code, you have to edit undocumented hacks over undocumented features, cruft from past experiments, workarounds for plugin bugs.
If one decides to clean up and refactor some recycled code, Ant supports rewriting and reaggregating the same process with different styles and structures, while Maven supports rediscovering what hacks make the plugins behave acceptably and facing a fresh dependency hell.
I find most articles like this severely damaging to burgeoning and worthwhile projects. Most people (like the author of this article, and some of its commentors) who critique a framework or language, have never actually used said framework/language to give it a fair review, and are just spewing the retoric their friends have told them. Who, incidentally, haven't used the framework/language either.
I'm an old hand at Ant. On my last job I used Ant extensively, and am able to scratch up detailed build scripts in a few hours of work.
I never used Maven 1, but had heard the nightmares from coworkers on getting it working, so I stayed away. On a recent project I had to use Maven 2 and found it interesting and easy enough to use, but never setup my own project, just was an end-user of an already established build process.
The other day, based on Will Iverson's article on java.net Building Web Applications with Maven 2 I ported an application to Maven 2 from Ant. It took me 1 hour to learn how to setup a project, and how to implement all the functionality from the previous build scripts.
The concept of Maven (particularly v2), is "convention over configuration", which provides you with a number of benefits. The first is that when a person who is familiar with Maven's basic build structure and process, can sit down at mostly any maven project and understand how it's built in minutes, not hours. This is not so with Ant, as people have a lot of free reign from project to project, and generally don't reuse previous scripts or generally accepted conventions. Mostly because they decide to write a new set of scripts so they can learn Ant themselves. Secondly, Maven has most basic tasks already written for you, even the creation of project files (which includes Maven, Eclipse and IntelliJ). I would say most new projects can and do follow a standard build structure, which immediately benefit from Maven's paradigm. Lastly, the concept of repositories blows any other build process out of the water. Why should I have to spend an hour finding and downloading relevant jars, docs and their sources for a project, when maven can do it for me, just by definition *and* add them to the appropriate classpaths. This benefit even increases when you have internal projects that your project depends upon, using things like SNAPSHOTs, and previous versions.
Having said all this, for very custom things, I still use Ant, and find it a very powerful and flexible utility. For most projects, Maven 2 just has Ant beat.
I suggest you take 20 minutes, read Mr. Iverson's article, performing the examples, and give Maven 2 a shot. You'll be as plesantly surprised as I was.
Hear, hear!
I still love Ant too. After all, Ant killed 'make' and for that we should be eternally grateful.
I think that Maven has a cool idea (the project object model) but the execution, doc, and tools (hello Jelly) in 1.x was painful.
Good execution and documentation is vital.
I really like Ant. I can usually get it to do what I want, although scripting in XML is pretty painful.
I recently ported a large project from Ant to Maven. It took quite a bit of work and I'm still figuring some things out, but I'd say the end result is worth. It forced me to modularize my code which seems to enhance the ability to use th code in other projects. Once you get how to work with Maven, it's really pretty simple (albeit verbose). Also, Maven support in Netbean's is top notch using MevenIDE. Haven't tried Eclipse's M2Eclipse plugin yet
The biggest mindset change is that if you need to do something custom in Maven, you write a plugin (usually in Java), which are apparently simple to write. This is in contrast to Ant where developers generally try to hack procedural stuff into the build script using XML syntax (Yuck!!).
Post a Comment