Thursday, August 17, 2006

Maven 2.0 - Transitive Dependency Problem

Although i really love the automated dependecy handling of maven 2.0 i think it's still buggy. At work we have a submodule of a business module (testroot) which has a lot of dependencies and as i executed the mvn site command to look at the generated dependency.html i found something weird.

In the transitive dependency section of the dependency.html, dom4j with the version 1.6 was defined. However i had a look at the dependency tree, dom4j was defined as a transitive dependecy of commons-collection.jar(version 1.2) but it had a different version namely 1.4.

After i executed the mvn -X compile and piped the output into a tmp.txt-File i found out that hibernate had also a transitive dependency of dom4j and that was the version which was shown in the transitive dependecy section of the dependency.html (1.6).

Because of this problem i had a look at the 'Better builds with Maven' online-book and i found the following:
With the introduction of transitive dependencies in Maven 2, it became possible to simplify your own POM by only including the dependencies you need directly, and to allow Maven to calculate the full dependency graph. However, as the graph grows, it is inevitable that two or more artifacts will require different versions of a particular dependency. In this case, Maven must choose which version to provide.

In Maven 2.0, the version selected is the one declared “nearest” to the top of the tree - that is, the least number of dependencies that were traversed to get this version. A dependency in the POM being built will be used over anything else.

That's why the transitive dependecy of hibernate is being used. But as you can see in the following screenshot of the dependecy tree, under hibernate there isn't a dom4j transitive dependency. So the mvn site command alternatively only the dependency-site is buggy.

If you have any suggestions how to prevent this problem please post them. Maybe with the next release of maven this problem will be solved.


1 comment:

Anonymous said...

Yeah what?
[b][url=" "]hydrocodone order[/url][/b]