Wednesday, 31 October 2007

[LazyWeb] maven pom trimmer plugin idea...

So its so easy for maven pom.xml files to get a little large; full of stuff they don't really need - or more importantly, full of stuff the end user doesn't really need to use your library. Its even easier for the stuff you depend on to pull in heaps of stuff you don't need.

e.g. ever picked the wrong clogging pom.xml section and shoved in a dependency on log4j, logkit and avalon on your project? (Its such a shame sun messed up the clogging space btw).

Its way too easy in maven to not really see or care what dependencies you really have, including those transitive ones - and we end up with lots of unnecessary crap. It can be a bit scary to run 'mvn site' then look at dependencies.html to see all the stuff maven's pulling in.

So here's the idea. Its a bit like Jester. When all your tests pass; you run the pom-trimmer; what it does is try removing bits of your pom to see if your tests pass. It tries all the permutations to figure out how much crap it can miss out. (So commenting out sections/>).

Next though is it should walk the transisitve dependency graphs and find all the transitive dependencies and try avoid those (using tags on the dependency) so it can clean your pom down to just what you really need.

We should try get into the habit of running this before a release so we can all try keep released pom's as free from junk as possible.

So any volunteers to hacking up this little Mojo?

1 comment:

jlorenzen said...

I know how you feel. In fact I just joined a new team and currently cleaning up their nasty poms and was actually thinking about writing something. Not sure I have the time but like the idea.
You also might be able to reuse some of goals available in the maven dependency plugin (http://maven.apache.org/plugins/maven-dependency-plugin/plugin-info.html).
Such as the dependency:analyze goal.