Tech Per

31 Jan

5 Good Things Maven Brought To The Table

Maven is getting a good deal of backlash these times, latest from Tapestry God Howard and from Graeme Rocher the Grails God, but I have also not been holding back myself. We get so frustrated sometimes, when tools doesn’t feel right, while at the same time, we cannot do better ourselves! I thought I wanted to do a little post of good things, that maven has brought to us. Things, that I for one would not like to be without. Things, that I think will stay with us in some form, even with forthcoming build tools of tomorrow.

1. Good, Standardized Directory Layout

A src and a target directory. The src directory neatly layed out with a main and a test directory. Even main and test directories are neatly organized into directories of the source types and resources. I love it. And I love the idea, that it had been sinking into most of us. I find I create this directory structure, even when the build system isn’t maven.

People fought this, all the way back in maven1. Maven won!

2. Component Based Development

Because of the ease of which we, with maven, can do multi-module builds and let modules depend upon each other, we tend to modularize our code much better. At least, that is my experience. I am getting smaller modules, with more clean separation of concerns the modules between. I like that.

3. Dependency Management

Even though this can also often be a source of frustration, I still think the idea of automatic dependency management is nice. I also think, that the maven implementation of it can be better. This is also something, that puts quite a burden on everyone releasing dependencies into the repository, as the dependency information needs to be correct.

4. One Place to Look for Dependencies

Well, nearly :-) Most open-source libraries and frameworks of today can be found in the main maven repository. There are also some other repositories around, but most of them are in the main repo. I like that I do not have to run around, scouring the web to find dependencies of dependencies of dep…. all in their correct version.

5. Dependency Naming Convention

Jars and distributions, that are released with maven, now have, what I find a good, sane and solid naming convention. This includes a version number in the filename. It also includes the classifier, like “javadocs” and “sources”. I do remember the days before maven, where it was indeed very common to download a zip distribution of library foo, only to discover a lib directory filled with a bunch of jar files, all without any version information in them. Not in the filename, and most of the time, also not in the manifest. You still see this, but it is very rare.

People fought this, as someone did not like the idea of including the version information in the filename. Maven won!

So, all in all, maven has brought a good deal of good things to the table!

4 Responses to “5 Good Things Maven Brought To The Table”

  1. 1
    Robert Says:

    I have not quite grokked the dependency problem. If you specify the version you want in the pom file does Maven much it up somehow?

  2. 2
    polesen Says:

    @Robert: Yes and no :-)

    There are several issues at hand.

    One is the automatic resolution. Say one transitive dependency depends upon foo-1.xyz and another depend upon foo-1.zyx, where “xyz” and “zyx” cannot be automatically sorted out. There needs to be a common versioning scheme. For instance, do libs use major.minor.bugfix or only major.minor, some write stuff like “-ga”, “-final”, “-alpha”, “-beta”, or “1.3b2″.

    Then there is the problem of a dependency being found in more than one place in the repository. Some are released under two different groupIds, which can make two transitive dependencies include the same jar in same version with different names.

    Another one is with spring. You can depend on “spring-full” (includes all) or spring-foo, spring-bar, … Now, one transitive dependency can depend upon spring-foo-2.0.jar and another transitive dependency can depend upon spring-bar-2.5.jar. Not a good match, when deployed in “lib” in the same war.

    The two cases above are special cases of A badly packaged project will break builds.

    There is also the problem of excluding transitive dependencies, where you need to know and specify ALL you do not want.

    Some of these are not mavens fault, but more the fact, that automatic, transitive dependency management is very hard to get right. I, personally, think we need more rules enforced in the repository, to be able to get a good implementation on top of it. It needs to be streamlined even more than it is today.

  3. 3
    Mike Funk Says:

    Congrats! You’re one of the very few who grok the power of Maven.

  4. 4
    bundleOfJoy Says:

    Forget pom.xmls casually packaged with jar files … OSGi bundles sort out java dependency, with the import/export manifest where it should be, tucked inside the jar and exploited at runtime as well as build time

Leave a Reply

© 2008 Tech Per | Entries (RSS) and Comments (RSS)

GPS Reviews and news from GPS Gazettewordpress logo