Tuesday, October 28, 2008

Tried Maven for Jibs

Over the last few days, I converted JIBS directory structure to work with Maven and got Maven to build JIBS. JIBS uses a three other jar files so I really like Maven's repsoitory. Unfortunately, none of the jar files I use are in the Maven repository.

So far so good. Based on my experience, if you are doing lots of smaller Java projects that need to roll up to a big deliverable in an orderly way, Maven is great.

I was particularly impressed with the strongly recommended directory structure (convention over configuration). Moving the files around not only made Maven work out of the box, but made the project more understandable and simplified my existing Ant scripts. Clearly an advantage if you are working on many projects since they will all have the same basic structure.

So, to recap, the good points were:
a) Maven does way more than Ant for its size
b) The dependency management features are great
c) The self-documentation features are great

But I won't be replacing my Ant scripts with Maven. Problem is that on the same code base, I compile for both Java 1.6 and Java 1.4. I do this by dropping a few source files and then calling the compiler with a 1.4 compile option. Opps, no readily apparent easy way to do this in Maven. (I'm not sure there is any practical way to do this in Maven.) Also, I unzip jar files and include classes in my distributable - making it a one click jar file (with an exe wrapper). Again, that's not a Maven kinda thing. So, I'll just stick with ant as my main build tool for the moment.

So here are the bad points:
a) You fall of the face of the earth very very fast if your project deviates from Maven's model.
b) The documentation is a bit sparse.

So, in poking around, it looks like Gradle could be good, but my Ant scripts are working just fine for now.

What do I suggest?
a) We adopt the Maven directory structure
b) We use Maven or other dependence management tool to manage all our modules/products/projects or whatever the heck we call them.
c) We use Maven for when its good (enforcing the directory structure at least...)
d) We use something else for when its bad

Gerhard

Gradle
Ivy
Ivy Review

Maven Issues #1
Maven Issues #2
Maven Issues #3

1 comment:

Jeffrey Erikson said...

Here are a couple good intro docs to Maven:
Maven: The Definitive Guide and Better Builds with Maven.


As well, you can change the Java version to compile for in your projects POM file. Basically, you'd create a build profile for each target version you want to build, then set the source/target options for the Maven compile plugin. Probably more work than you want to go through right now, but it's not really that hard. Here are some good references for that: profiles and compile plugin