I’m down with the ‘flu today, so I thought I’d do something to take my mind off it and check out Maven I’ve been somewhat critical of Maven in the past, but only tentatively as I’ve never really played with it. So I thought I’d rectify that.
I had a small little toy project lying around that I thought would be a great fit. It’s got a moderately sophisticated Ant script similar to the ones I use at work. I decided to get it working under Maven.
So off I trot to the Maven web site, and download Maven. I follow the install instructions, and pretty soon I can do a
robertdw@elysium repoman $ maven -v __ __ | / |__ _Apache__ ___ | |/| / _` V / -_) ' ~ intelligent projects ~ |_| |___,_|_/___|_||_| v. 1.0-rc4
Okay, that wasn’t hard. So what’s my next step? According to the Getting Started With Maven guide, it’s creating a project descriptor, called project.xml. They’ve got an example one, and a page detailing what’s meant to go into a descriptor, so I follow through and make one. So far so good, and maybe 30 minutes effort spent so far.
Problem number 1: I knew it was too good to be true. 🙂 This particular toy project uses Subversion for version control. Maven supposedly supports subversion, but there’s no example in the repository section. Still, I make a stab at it, and put in this:
Okay, moving on. I’ve now got a project descriptor. How do I use it to simply do a compile?
This had me stuck for a while. The “Getting Started” guide had an example of how to create a JAR or generate the web site, but there was nothing on how to simply compile the code. Nor was there anything in the “Getting Started” guide on where to go next. Somewhat stumped, I do
maven -help, and find out I can list the “project goals” using
maven -g. I’m guessing here that goals are something similar to Ant targets, based on things I’ve seen before, but I don’t know… there’s nada about ‘goals’ in the Getting Started guide.
Hunting around in the rest of the Maven doco, I get a confirmation that goals are things I can invoke on the command line, to get stuff done. I also find a big list of Maven plugins in which I find that I can do
maven java:compile to do compilation. Yeah! Step two complete, after only about another 60 minutes.
I’m really starting to feel out of my depth here; The
maven -g I did earlier showed me that there’s a bucket load of goals out there, and I don’t know anything about them. I don’t even know how they heck they got onto my system; somehow Maven brought them down for me. Certainly I didn’t do anything to suck them down. And they’re interrelated: I know, for example, that doing
maven site:generate kicked off a lot of work, including running unit tests. However, I don’t have a clue what the relationships are.
(BTW, while getting
site:generate to work, I found out my guess on the repository format was wrong. Still don’t know what it should be; I had to take the repository section out in the end)
And that’s basically where I stand now. I’ve invested about 3 hours all up, and I’ve got
site:generate to work for me, sans Subversion support. And I don’t really have a clue about how the magic is occuring behind the scenes. I can also see that it’s going to take a lot of reading and experimentation to get the same level of functionality in Maven as I do under Ant.
Well, if I’d given Maven the 10 minute test, I’d have tossed it out the door quick smart. 🙂 3 hours, however, is a decent dip in the water.
One of my long-standing concerns about Maven is that you sacrifice a lot of control to use it, and this one hasn’t been dismissed. Case in point: I could not get Checkstyle to go over my test code, something that is trivially easy in Ant. If you happen to like how Maven does things, that’s not a problem, but I’m not sure I do.
I’m really concerned about how hard it is to figure out what the dependencies between goals is. There seems to be little documentation on it; the couple of times I saw it documented, it was definitely incomplete (take the site:generate goal for example). I see little recourse besides trial and error to figure it out, either.
I’m impressed by the quality of the generated site; it’s a nice little snapshot. But I don’t have a clue as to how to customise it.
I like how much is present “out-of-the-box”; the information generated by default was impressive, and covered similar reports to what my Ant script generates. But at the same time, it’s overwhelming.
Overall: I’m still not sold on the tool. The concept, yes, but I’m not at all sure about the implementation. The doco, at least, needs to be better improved, particularly in regards to the dependencies between goals, a more low-level walk through, and examples.
I’ll probably invest some more time in the future in it, but I’ve had enough for now. I don’t think Maven’s for me, but I’m still willing to give it a chance when I get some more time again. I can see the value for open-source and personal projects, in particular, but not so much for the sort of internal development work I normally do.
 700 lines of text, with a likely ratio of about 3 goals per 4 lines.