February 10, 2005

Ant and Maven

                                

I was going to post a comment on Dion's blog about his entry on Maven when I realized that Mike posted it for me...

In short, ant's <import> and <macrodef> are absolute life savers.  They have brought a lot of sanity into my build files, which I thought were already pretty lean and mean:

  • All my build files have shrunk a lot thanks to <macrodef> ("extract method").
  • All the targets contain fewer commands, and they clearly state their intent thanks to well-chosen names ("keep methods short").
  • The macros contain a set of sensible defaults that make most of their invocation straightforward and with rarely more than a couple of parameters ("program for the default case").

These rules of thumbs coupled with the following simple guidelines:

  • Everything that may vary from an installation to another should go into a build.properties, all the rest goes into your build file.
  • Break down your build files logically (e.g. I like to have all the macros defined in build-macros.xml and <import> it everywhere I need it).

... give me a feeling of empowerment and control over my infrastructure.

Another important point is that I only need to know two languages to find my way in ant (Java and ant's XML) while Maven requires me to learn four different languages:  Java, ant's XML, Maven's XML and...  gulp... Jelly.

I still like the idea behind Maven but even today, when I see that the same criticisms we were hearing two years ago still crop up on a regular basis, it doesn't make me very confident on my ability to diagnose Maven meltdowns.

Posted by cedric at February 10, 2005 11:15 PM
Comments

Would you mind sharing your build scripts? I suppose you must have "template" scripts for new projects...

Posted by: Daniel Serodio at February 11, 2005 07:43 AM

Yes, I looked into Maven recently and wondered if the overhead of learning it (and teaching it to the employees where I consult) would be worth it. When I saw Jelly as the scripting language I dropped the idea completely. Scripting in xml just doesn't seem like the best idea.

I haven't played with ant macros yet but the import saved my butt on my last project which had many modules.

If you are allowed to share some of your macro templates please do so.

Posted by: George Coller at February 11, 2005 08:33 AM

Check out Savant. It gives you dependency management even better than Maven's (it finds the transitive closure of dependencies if you've specified the dependencies of your dependencies, etc), plus it lets you keep your Ant build with just a few additions.

Posted by: Jason Carreira at February 11, 2005 10:55 AM

Check out the build setup that Howard has created for Hivemind called Hivebuild. He uses macrodefs fairly extensively.

Posted by: Bruce Snyder at February 11, 2005 08:07 PM

On the Maven userlist, Jason said that maven 2 will drop Jelly in favor of plain old java and other, better xml scripting languages.

Posted by: Geoffrey at February 12, 2005 09:06 AM

I doubt Maven 2 will ever see the light. Too much energy has been spent in more than 2 years to create chaos.

If they create a version 2 it will be incompatible with version 1 (even with micro releases it was already hard to have somewhat backward compatibility) and it will make existing Maven builds and the loadcrap of plugins complete history which is not what people want to heard.

But Maven people like to mess around the build all the time, so sure again they will convert existing build 1 version to version 2 alpha pre release to create more havoc. :)

Posted by: at February 12, 2005 09:42 AM

I really like the concept of Maven. While the execution does fall short in some areas with Maven 1 I do hope it provides impetus for other projects to create a higher level build system on top of Ant that provides a default means of dependency management, multi-project relationships, and generation of build artifacts such as jars, wars, and ears.

Perhaps it's Maven 2 or perhaps someone creates a suite of Ant macros. Either way there's a real need for higher level build systems to enable people to jumpstart their projects.

I don't want to have to maintain "my" set of macros to build build source, run unit test, and generate a WAR when every other company out there is doing it in almost the same way. I want to see reuse on the inter-company level and that I believe is the aim of a high level build system such as Maven.

Posted by: Todd Huss at February 13, 2005 07:21 PM

With Ant you have to have people who can code in Ant, and are happy with XML.

With Maven you just need people who are happy with XML.

Yes you can extend Maven with Jelly, and you can extend Ant with Java, but for most projects you shouldn't need to.

Posted by: Henri Yandell at February 17, 2005 06:47 PM

Cedric - Thanks for the pointer to the macrodef and import tags. I have used this knowledge to create the first video game written in Ant. It has a nice skiing theme. http://jonaquino.blogspot.com/2005/02/first-video-game-written-in-ant.html

Posted by: Jonathan Aquino at February 25, 2005 01:28 PM
Post a comment






Remember personal info?