Send As SMS

Tuesday, February 07, 2006

Working with Maven 2

I had not used Maven 1.X. I remember giving it a test drive, but a lot of it made me shiver. It seemed like a lot of learning and a lot of quirky behavior for something that was supposed to help me.

Looking at Maven 2, it seemed like a good place to start. I heard "total rewrite" and was a little scared, but I figured that the Apache folks had their shit together. The quick start guide was helpful and it did what I needed it to do right off the bat.

My whole point was that I wanted to put no effort into the build process. I am doing almost everything myself and I didn't want shit like the package process to hold me up. Here is what I needed m2 to do:

- run my junit tests
- package the APIs as JARs
- package the web-apps as WARs

I even sacrificed setting up the deployment of my WARs to my app server web-apps directory. Simply, I knew Windows would poke it's ugly head and I'd be pullying my hair over backslashed backslashes, or spaces in file paths or something terrible like that. I figured a drag and drop of a WAR was the least of my hold-ups.

Also, one nice feature of m2 is setting up dependencies, and since the app1-core was packaged as a JAR, that meant in the app1-webapp pom.xml, I could set up that JAR as a dependency meaning I just add to package app1-core and not deploy it anywhere.

Getting tests tested quickly, JARs built quickly and WARs built quickly was easily achieved. Here are some things that really screwed me up.

Downloading of dependencies and plugins. When you first run mvn, it needs to download all the plugins and dependencies. Well jaysus, I just fuckin downloaded the program, why didn't the plugins come with it? You watch line after line after line of new plugin being downloaded which is sort of a drag.

Then I started adding dependencies like junit, spring, struts and hibernate. This was pretty easy, although when m2 sets up its repository, it also downloads all the dependencies that *those* jars have. Again, you watch your screen flicker with new downloads and wonder if it is all working properly. You also have the problem of Sun Jars not being stored on the Maven JAR repository.

Can't find a jar? don't know it's heirarchy or version? Easy browsing here.

One problem with m2 is that it seems to have little patience if it doesn't find a jar that you have double-checked is in the repository. I got hung up on the struts jar for 3-4 tries running mvn, and it finally was able to download it. A better message than "download it manually yourself" would have been better.

This was all I needed to get started though. I don't really need m2 to build me a project site or documentation yet. But knowing that it can do that is fabulous. Now, I get away with these few basic commands

Test:
mvn test

package the API into a jar:
mvn package

package the web-apps into WARs
mvn package

(yes, the same, in the POM you just declare what the package type is)

I may be skipping over some other headaches I had with m2, but I think they mostly had to do with poor documentation. The topics for the documentation don't really follow and rhyme or reason, and they really vary from complete to scant to the obscure. They go from "getting started" right to "mini-guides". Not good, not good. Documentation should be more procedural, especially something as big as maven.

Overally, i give m2 a 8.5 out of 10 for "suiting my needs with minimal headaches".

2 Comments:

At 7:57 PM, Robert Hanson said...

This is helpful, thanks. For me I think it means that I am going to stick with Maven 1, because I am already familiar with it, and I have no problems with it.

 
At 10:42 PM, Mohan said...

I have recently started working with Maven 2 and has been facing a steep learning curve.

It would be cool, if you can post some of your pom.xml files that can serve as a quick dirty tutorial too.

 

Post a Comment

<< Home