Building a Better Maven with Ant
It looks like the Ant folks are thinking of building a better Maven.
I see many developers adopt Maven because they want a build system able to
provide common features with no effort. Most of them don't want to spend
much time writing an Ant script, or have seen or heard that maintaining Ant
build scripts is troublesome. So they choose to use Maven only because it's
easy to use for common use cases: install, write a simple pom of a few lines
or generate it using an archetype, and you're ready to compile, test and
package your new project following the Maven standard structure. They also
get dependency management for free, and with only a few more effort they
have multi module builds, and some nice features like code analysis,
coverage, and a set of report gathered in a web site. That's really nice and
that's what I like about Maven.
But Maven suffers from a lack of flexibility and robustness IMHO. And later
the same people who first adopted Maven because of its perceived ease of use
become frustrated when they need to tweek the system to their own needs or
don't understand how the release plugin work. Then some of them go back to
Ant, first having to go through a sometimes painful road to describe their
whole build system in xml, especially if they aren't Ant experts. Others try
to use new build tools like raven, buildr or others.
I really like Ant, and think it is a very good basis for robust and flexible
build systems. People with enough knowledge of Ant can write very good build
systems, testable, maintainable and adaptable. But you need to get your
hands dirty, and you need to get a good knowledge of some of the mechanisms
which can make an Ant based build system manageable: import, scripts and
scriptdef, macrodef, presetdef, and so on. [Read More]
What do you think - is this a good idea?
I agree that Maven has its warts, but I don't think it's that bad. I've also heard that Maven has been successfully implemented at large companyies like eBay, Intuit and E*Trade[1]. Is the "Maven sucks" meme largely something that exists in the blogosphere, but not in the real world?
I think the biggest benefit of Maven is dependency management. I think it makes your code more modular and easier to build. Rather than having a monolithic source-code tree that depends on itself being built in a certain order, you can have individual modules that pull dependencies from a central location. This can be done with Maven's Ant Tasks as well. I don't see a problem with building a better Maven with Ant, but to try and build a better Central Repository sounds like a nightmare to me. The current repository has been improved for years and is much better than it was a couple years ago. That being said, I would love to see somebody build a more accurate Central Repository. Ideally, it'd be done sometime next week.
[1] I could be wrong about these companies. If you're a developer at one of these companies, please confirm or deny. Any comments on Maven's success at these companies would be great as well.
Update: Speaking of Maven, there's an interesting comment on a Javalobby post I wrote:
With all the critical remarks the Maven project is receiving, wouldn't it be time for some Maven project lead to step up and explain the team's position? Or is it completely deaf to the sentiments? How many builds have to fail, how much more headaches are needed before others start their own version of Maven and do it the right way (like Don [Brown])?
Seems like an excellent question to me. Guys?
I'd go one step further and say that the *only* reason to use Maven is dependency management. That's the killer feature that you can't live without. The project management model it provides is clunky and complex, but being able to call out specific versions in different profiles is something that's really powerful.
In other words, the repository is what matters, not the project model. Tools that operate with the existing repository, like raven and buildr, give you what you need to have without burdening you with what you don't.
I've done a number of highly complex builds, and I've come to the point several times where I wanted my builds to be in a real language like Ruby or Groovy (or even Java) instead of XML. I'm wary of trying to push Ant even further toward being a language -- that way lies only heartache and poor maintainability.
Posted by Ben on February 11, 2008 at 09:18 PM MST #
I think they should be cautious. Maven does work pretty well and it really sucks when you start a project and have to pick between two tools that both seem to do the same thing and are both equally popular. It's a lot easier when the only choice is maven. Perhaps they should contribute to the maven project itself.
I would argue that this is pretty similar to the birth of subversion, which in my opinion created a bunch of new problems while attempting to solve a couple of annoyances with CVS. It doesn't really seem worth it. I still prefer CVS simply because of the more solid eclipse integration, since it would otherwise be a toss-up.
Posted by Al on February 11, 2008 at 09:19 PM MST #
This sounds like Ant2, or Magic, or Centipede, or the early-early betas of Maven 1.0. It's not a bad idea for people who know and love Ant, and maybe the timing will be better for it now. The Ant community is certainly more receptive to it these days - I can remember some members being totally against any form of remote dependency management earlier on.
Maven's approach is just different, and some people love it and some hate it. I think the "strict confines" it imposes are one of its strengths, and it's the thing that appeals to large development shops where consistency across projects is important. And frankly, while I hear a lot of complaints about lack of flexibility, I don't think it's what really burns people.
I think that is simply inconsistent behaviour and bugs. And the Maven developers are completely familiar with what the issues are - most of them are on the roadmap. However, the core development community has been pretty slow moving for some time (for a number of reasons, but one is that 2.0 actually works for a lot of people once you get past the hurdles, and so there's fewer itches to scratch).
Maven needs more people like Don to just try things, submit patches, and be vocal to get it accepted (as much on the dev@ list as on blogs :). I personally welcome the work he put in, even it is a little hyped :) He's triggered some people taking action again on the dev@ lists.
Maven's users should be demanding incremental feature releases that include such things, instead of waiting for the next version which will "fix everything". Normal caveat applies that in open source, often demanding something as a user leads to the previous paragraph :)
Posted by Brett Porter on February 11, 2008 at 10:16 PM MST #
I'm waiting for the EJB 3-ish version of Maven. Something that is less heavy-handed. It may or may not come from the Maven people. For a while I thought it was (Apache) Ivy, but I'm feeling like they love configurability more than simplicity. They're making strides though.
Posted by Paul on February 11, 2008 at 10:26 PM MST #
You can absolutely build pretty cool stuff with Ant. But I would also say that you can build really cool stuff with Ant + Ivy. Having done this before, you can cover many useful Maven features with just a few hundred lines of XML and two days of tinkering.
I am doing builds with 50 or so of my own modules and hundreds of dependencies with this type of setup. Most of my module builds only require a few lines of XML and the Ivy file (POM). Ivy will then figure out the build tree, and off you go firing your Ant module builds in the right order. Ivy will also take care of grabbing all my dependencies that I need.
You can ask why spend two days tinkering when you could be done in minutes. I guess the benefit is that I am in full control and I can modify the build easily any way I want. I also do not have to worry about many of the problems that might show up with Maven.
I definitely do not see people go building things like these instead of using Maven, but if you can, and you will get a lift out of it, then why not. If there is a standard system, then it really is a question of which one is better. I think Maven could use a little competition in this space. At least people would have two reasonable choices.
Posted by Tero on February 11, 2008 at 11:02 PM MST #
Posted by Peter on February 11, 2008 at 11:14 PM MST #
Posted by Glen on February 12, 2008 at 12:27 AM MST #
I am sorry I was not clear. That several hundred lines of XML were reused with Ant imports in all the projects (= a lot of them). By doing this, I actually reduced the build file sizes over 95% from what they were before.
The actual XML you write to build the modules is often less than 10 lines of Ant XML. And even when you want to customize the builds, it is often easy just by using task injection points in strategic locations, or by overriding the tasks that you need. You can also heavily use macros for most common things so you can do one liners for what used to take 30.
To put this in contrast with Maven that took years to develop - two days of tinkering to get similar benefits is pretty good IMHO. Any average guy can do it with Ant + Ivy and be in full control, and the stuff just builds every freaking time. No fuss.
To be fair, these builds require public maven repos but they are just not a viable choice for any serious builds (=too flaky). Therefore I use local staging repos and individual repos for each developer to do their isolated builds. I can then fix the borken POMs in my staging repos.
Posted by Tero on February 12, 2008 at 04:52 AM MST #
Personally, I think Maven Rocks!
My biggest problem with Maven is that not everybody uses it. If every project had a decent pom and artifacts properly organized on Ibiblio, it would make using Maven MUCH easier...
Besides dependency management, the sites are key. The fact that I can define static code analysis checks and reports, test coverage reports, etc. I know I can do all of this with Ant, but I prefer the Maven framework.
Once developers see what Maven can really do, they get hooked.
Posted by Anthony on February 12, 2008 at 06:10 AM MST #
Posted by some guy on February 12, 2008 at 09:27 AM MST #
Posted by Magnus Heino on February 12, 2008 at 09:47 AM MST #
Posted by Chris M on February 12, 2008 at 03:56 PM MST #
Posted by Niall on February 12, 2008 at 05:32 PM MST #
Chris M: You need a Maven proxy and a own repository. Look at Artifactory. It will solve all of those problems.
It's also really easy to write your own Maven plugins. Just write a plugin that verifies that no "unwanted" artifacts are included.
Posted by Magnus Heino on February 12, 2008 at 06:30 PM MST #
Here's a quite interesting post from Howard Lewis Ship on similar topic:
http://tapestryjava.blogspot.com/2007/11/maven-wont-get-fooled-again.html
I personally would prefer a mix of Gant expressiveness (Ant but with Groovy instead of XML) plus a kind of "project templates". Dependency management should be optional imho, because quite many projects want a closed/frozen environment.
Posted by Victor on February 12, 2008 at 11:40 PM MST #
Posted by David Whitehurst on February 19, 2008 at 11:52 PM MST #
I think the gradle project got things right:
1. you can easily use any ant task
2. there's a model for defining dependencies, that uses ivy
3. plugins can provide model objects a-la maven's pom. they can also provide standard targets (so to build a standard jar, your build file is just 'usePlugin("java")'.
4. you can rewrite any target
5. each module has an object representing it. then, in the root build file (or any module's build file) you can manipulate these objects, rather than needing to create a build file in each (even if it is just 5 lines). but, if you do have a build file, it inherits methods & variables from its parent (the one that defined to use it).
6. build scripts are groovy, so you have methods, control structures etc.
7. cross module target dependencies. so you can generate sources in module M1, then compile module M2, then compile module M1.
Posted by Ittay on June 10, 2008 at 08:40 AM MDT #
Posted by waiting_for_maven_to_die on August 07, 2008 at 10:21 AM MDT #