Reputation: 93
We use Maven in the large corporate IT shop I work. The dependency hierarchy seems to become unmanageable very quickly even if I just need to add one new dependency. On small changes to the code base I find I spend more time debugging Maven problems then the actual code. I am looking for some direction on how to
Thanks!
Upvotes: 4
Views: 6683
Reputation: 1246
I would give the following advice for untangling maven dependency issues. First off I would take advantage of the mvn dependency:tree
goal from the command line. This will give you a nice tree of your dependencies and will make it easier to figure out certain version conflicts (i.e. Hibernate is using a version of log4j that conflicts with your slf4j dependency). As far as a good way to visualize circular dependencies, the m2eclipse plugin for Eclipse has some very good visualization utilities to help you sort this out. Finally, I would suggest defining the versions of your project dependencies in you root pom.xml through leveraging the <dependencyManagement>
feature so that all versions are managed in one place and this will allow child pom.xml files to only declare <groupId>
and <artifactId>
.
Upvotes: 2
Reputation: 20245
This command should be your best friend: Resolving conflicts using the dependency tree.
How to design new software to avoid the tangled web of circular dependencies?
I'm afraid there is not clear and easy answer and there are many approaches of course but I would say it is better if you have a dedicated (team/mini team/one person?) that is responsible of taking care of all Maven stuff in your organization. They should analyse the dependencies and if there are any requests to add a new dependency to the project, they should approve/reject it.
Upvotes: -1
Reputation: 7044
I would recommend that you use the eclipse maven plugin (m2e) - it has an excellent graphical dependency viewer that should enable you to track down dependency conflicts quickly. It actually provides two views - a tree view and a "hierarchy" view. I prefer the hierarchy view since it lets you search and filter transitive dependencies and highlights conflicts.
Upvotes: 1