Maven doesn’t work for me
I sometimes joke that I don’t know anything at all, I just know people who do know things and ask them what to do. The joke is that this is partly true – in software development it’s impossible to know everything, so it’s important to rely on people you trust. Which brings me to Maven 2.
I’ve had a number of people that I respect recommend that I start using Maven 2, so I thought that I would try it on a project that’s just starting out. On the other hand, I heard from people on related projects that they’d tried it without success. No problem, I thought, I’ve got access to some people who have used it, who have a fairly good idea of what I’m after in a build, and I’ll be able to get some guidance from them. Given that I had conflicting advice and I was the one advocating Maven, I decided I should do the implementation myself rather than delegating the potential pain to someone else, and that’s what I did.
I’ve spent a day and a half on this and got something that’s working ok, but when I get to work today I’m going to back it all out and go back to the Ant-based approach that other teams are using. Why? Because although Maven 2 may work, I can’t make it work the way I want it to (the “I” in that sentence is quite important).
First, I love the Maven 2 dependency mechanism. It’s great, and even though Maven doesn’t rock my world the experience has encouraged me to go and look at Ivy (though that’s in the future). My problem is that Maven 2 wants me to conform to its view of the world, and that doesn’t match what I want to do. That would be fine if there were plenty of hooks to let me do it my way, even if that was expensive, but either these hooks are missing or the documentation on how to use them is nonexistent or inaccessible (and it’s probably a mix of all of these).
So what do I want my build to do that’s “non Maven”?
- I want to run separate unit and integration tests in one project, and have reports (test results and coverage) for both of them, and I only want to run the tests once to get it. There is a note in the documentation that says that Cobertura will force the tests to run twice and that this will be fixed in future, but every configuration I tried ended up running the tests even more than this.
- I want to be able to package the code with instrumentation, run integration tests using this code in a WAR, and measure the coverage.
- I want Checkstyle (and Simian and Complexian) to run over all my code, including the tests
I tried separating the integration tests into a separate module and deploying a jar from the “core” module to the integration module, but that didn’t give me coverage of the integration tests because the code in the jar wasn’t instrumented. The alternative seems to be to compile the code again so I can run the integration tests over it – this seems like a great big hack, and seems to predict more great big hacks down the way.
The idea behind Maven 2 is great, and if you’re happy with the outcomes that’s great, but the current implementation and documentation doesn’t provide the level of customisation I’m looking for.
If anyone has a POM that handles the three points that I would like in my build, than I would be more than pleased to receive it and blog about my experiences using it. I want Maven 2 to work for me, and it’s disappointing that it doesn’t.






The problem I have with Maven is it wants to “own” my project; it want’s to “be” my project. It feels much like having a project that will only build (and in many cases run) inside my IDE.
So, having some alternatives, I think ivy is far better in that it’s something you can include in your own project not the other way around.
Your mileage may vary
We’ve switched to using Maven at Wotif, and it’s definitely been a mixed bag.
For many (I’ll probably even go so far as say most) modules, it works just fine. If the module simply produces a JAR, then Maven’s a winner. If, however, it is more complex, or you want to do something a bit different to the Maven “best standards”, you’re out of luck.
I like what the Maven guys are trying to do. And, for any random project, using Maven is almost certainly smarter than using Ant. But there is a small but significant percentage of projects where using Maven is going to cause you pain and suffering.
On your exact complaints:
* using Clover, we can get our tests run just twice (once with Clover, once without). However, we can’t run Clover and Checkstyle in the same build invocation.
* I haven’t done the “package the WAR with instrumentation” deliberately, but I did it by accident, so I know it can be done.
* The Checkstyle plugin says it goes over test code – it’s even got an option to include test sources. But it doesn’t. Go figure.
Personally, for my money, as opposed to my employer’s, I’d go Ant + Ivy. I’ve had a lot of success with that, and I found the Ivy dependency management story to be significantly better than Maven2. The one thing you find that you miss is the plugin support – particularly the ability to change a plugin and roll out the change instantly.
To run checkstyle on all your code including the tests put “includeTestSourceDirectory” true in the configuration section of the maven-checkstyle-plugin, just near where you would have defined the configLocation for the checks XML your using.
For the rest, I’ll put together the POM your after and send it through a.s.a.p.
It’s a pitty your not finding out how good the release and deployment features are, since these coupled with the dependency management make Maven 2 a treat to use, at least for me they have been.
It looks like there isn’t a maven2 plugin for Complexian so I’ll look into writing this since I’d like to use it as well.
Ah there is a simian plug-in so that should make things a little easier in that regard.
http://mojo.codehaus.org/simian-report-maven-plugin/introduction.html
Ok I should have checked first, the simian plug-in is for Maven 1, so I guess Ill do one for Maven 2.
*sigh* there’s a few days that I’ll never get back in my life, trying to _guess_ the way that maven 2 wanted me to structure my project, then trying to make it do something slightly different without too much xml ugliness. Ultimately I tossed it all out and went with a different more familiar form of xml ugliness (ant).
I agree I love the principle of maven and I’ve seen it kind-of-work for a bunch of little projects, but once you get to a certain tipping point it is just too opaque and clunky in it’s extension points.
For dependency management from ant, I’ve used the maven ant tasks (http://maven.apache.org/ant-tasks.html). which are quite sane. I prefer ivy myself but for a team familiar with maven already the maven tasks are simple.
Here is a post I did about adding a tasks to an integration-test phase in Maven2. http://jamesladdcode.com/?p=63
I think that Maven2 is not that hard to extend but I don’ think the available documentation is very good.
A Maven Developers Handbook for version 2 would be great.
Here is the post about calling complexian and simian http://jamesladdcode.com/?p=66