开发者

View a dependency tree in Maven?

开发者 https://www.devze.com 2023-03-22 14:21 出处:网络
I\'d like to make sure I\'m not including duplicate libraries in my Maven project. I\'m pulling in quite a few dependencie开发者_如何学Pythons from a few different repositories including main, Spring\

I'd like to make sure I'm not including duplicate libraries in my Maven project. I'm pulling in quite a few dependencie开发者_如何学Pythons from a few different repositories including main, Spring's repo, and JBoss' repository. How can I see a graph of the dependencies so I can make sure I'm not depending on multiple versions of a single library?

It would be kind of a bummer if I was including something like org.springframework:spring-core:3.0.1.RELEASE and org.springframework:org.springframework.spring-core:3.0.5.RELEASE which actually do show up as different dependencies, as weird as it sounds, because Spring's repository names things weirdly. What can I do to make sure I don't have duplicate dependencies?


The dependency:tree maven plugin should do what you want and show the tree.

Alternatively force Maven2 to copy dependencies into target/lib to copy the the artifacts in the target/lib directory which should also show duplicates but you would still need to grep all the POMs in the ~/.m2/repository to see which library is pulling in which version manually and that would be time consuming for large local repositories.


Duplicate libraries can be a problem, but duplicate classes can exist even if no libraries are duplicated. JBoss Tattletale can analyze a set of jar files and produce a report which lists all duplicated classes. There’s a Maven plugin for running the report - see http://docs.jboss.org/tattletale/userguide/1.2/en-US/html/maven.html


If you'd like to get a graphical, searchable representation of the dependency tree (including all modules from your project, transitive dependencies and eviction information), check out UpdateImpact: https://app.updateimpact.com (free service).

Using the search, you can find out how many times a given library is imported, by what modules and in which versions, as well as verify if older versions of a library are evicted by newer ones.

Disclaimer: I'm one of the developers of the site

0

精彩评论

暂无评论...
验证码 换一张
取 消