Maven – I’ve just discovered Transitive Dependency Management

10 Mar 2010 – Denver, CO


Wow. I have to admit to being a little late to the party on this one. Several years ago, my days as a full-time Java developer where filled with ant (if you were lucky) and make (if you weren’t).

Before I continue, this evenings late night festivities are brought to you by this (ultimate) form of nourishment:

Tayto crisps

And this fantastic album:

Tangerine Dream - Ricochet

Anyhoo, this evening, I planned on spending a couple hours playing with hibernate (I wanted to check out its ORM capabilities, especially compared to Rails ActiveModel (which I love)). 5 minutes into the tutorial and I was in jar-hell and for the millionth time starting thinking “where do I download that that mysql-connector-java” (its here for those of you that care) as I started to think about hooking hibernate up-to mysql.

But not this time. Introducing maven. The best description of that I can think of is ant coupled with something like yum or apt-get or macports or whatever. Its kind of like a RubyGems for jar files.

Here’s a sample POM file, from the hibernate tutorial:

<name>First Hibernate Tutorial</name>   

The bit we care about are the dependencies. Lets kick off a build:

	~/java/tutorial $ mvn compile
	[INFO] Scanning for projects...
	[INFO] ------------------------------------------------------------------------
	[INFO] Building First Hibernate Tutorial
	[INFO]    task-segment: [compile]
	[INFO] ------------------------------------------------------------------------
	Downloading: .../maven-plugins-12.pom
	Downloading: .../maven-parent-9.pom
	Downloading: .../apache-4.pom
	Downloading: .../maven-plugins-8.pom
	Downloading: .../maven-parent-5.pom   

And look at that bad boy go! Good lord, it actually fetched 40 jars, stored them locally in my repository, and used them in the build. Dependencies and everything. Glorious. I have to admit to being more impressed this evening with maven than hibernate (which is actually fine, I’m just a little spoilt with ActiveModel).

The source for the hibernate tutorial is here for safekeeping.

Tomorrow I need to burn 44 gigs of VMWare instances onto DVDs and post them to a data-center in Florida. Wonder how long it will take. I figure its easier than trying to FTP them.