mercredi, mai 27, 2009

My wishes for a better Maven 2

My main concern with maven builds is their lack of stability. Mostly in terms of dependencies.

This is why I think that the following simple (apparently as I guess implementing them, though it seems simple to me, would possibly imply errors in exotic plugins) wishes would save the day of a whole lot of people (including of course... me ;) ).

First things first: Exclusions.


In a perfect world, everybody would declare dependencies properly (with a proper scope defined for
each, and optional dependencies declared... optional...) and versions resolutions for conflicting dependencies would work exactly as expected.
If you have used any of the repositories out there (even official ones) you know that some weird dependencies can irrupt in your project's Manifest.mf file, WEB-INF/lib folder, or any other proper place to put transitive or direct dependencies of your artifact.
Moreover, if you are building complex multi-modules project, you'll know that versions are not always resolved as they should.

Right now, the only option is to exclude artifacts one by one. What a pain in the arse!
Please please please, add wildcard exclusion!!!, or even better, a <transitive>true|false</transitive> element to the <dependency/> element.

One step further: I don't care about transitive

In some cases, you'd want to experiment, or are quite sure about the dependencies you want, but for a precise reason, don't want to retrieve any of the transitive dependencies.

It would be really nice to add a <transitive>true|false</transitive> element to the <dependencies/> element of the pom.

You would then be able to declare all the dependencies of your project without relying on transitive mechanisms.

This would really be an asset when you are handing over your build to maintenance, or building a stable release.

Even better: How about making this automatic

How nice would it be in this case that when the project is in the early dynamic phases, you specify your basic dependencies and retrieve the rest transitively, and...
...then...
At some point where you want to stabilize things or be sure of the outcome, you just launch for example: mvn dependency:flatten and "Voilà!" your pom.xml now contains all your project's transitive dependencies, with appropriate scopes computed, and the aforementioned <transitive>false</transitive> element added to the <dependencies/> element.

I for myself would find this very intuitive and simple to use, without interfering with the current behaviour of maven at first glance (backward compatibility my friend!).

For something completely different: splitting the local repository


This last wish is likely to remain a wish as I think it would require too much work.
But it's a sad thing that the local repository is not split between a plugins repository and a artifacts repository in some way.
The plugins repository would contain plugins and all their dependencies, and the artifacts repository would contain other artifacts and their dependencies.
This would disallow the intrusion of plugins' dependencies in your build.

Though this wish would not be a real issue anymore if the previous wishes could be granted.

To sum it up: Dynamics and Automation, plus Control!


Maven 2 is a great tool and offers a very good way to have build with dynamically changing dependencies. When set up, you don't always have to go and look for the latest build of your dependencies, and can automatically retrieve them.

Though sometimes, a bit more control is needed, and it would be very nice to have this kind of choice.

EDIT: After wishing I did my homework and went voting for http://jira.codehaus.org/browse/MNG-1977 Go there and vote for it!!!

1 commentaires:

David Dossot a dit…

I would love to be able to re-scope/de-optionalize a transitive dependency, so I would not need to redeclare it and keep its version in sync with the transitive one.