Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find dependant (reverse dependencies) in maven project

I'm trying to find a command that does the opposite of mvn dependency:tree. I want to find out all the projects that depend on a specific module. As trivial as it may sound, I couldn't find such thing.

The use case is in order to find, in a very large project, if I can delete a module or if there are other modules that use it as their dependency.

like image 240
Avi Avatar asked Jul 17 '14 17:07

Avi


People also ask

How do you find transitive dependencies?

First go to View → Tool Windows → Maven, to make sure that the Maven window is visible. The top-level elements in the tree are your direct dependencies, and the child elements are the transitive dependencies.

Where can I find dependencies in Maven?

In your project's POM, press Ctrl and hover the mouse over the dependency. Click the dependency to open the dependency's POM. In the dependency POM, view the active dependency, its transitive dependencies and their versions. You can check the origin from which the dependency was pulled in.

What are reverse dependencies?

A reverse dependency – meaning another package depends on the existence of your package Note – Use the reverse dependency type only when a package that cannot deliver a depend file relies on your package. An incompatible package – meaning your package is incompatible with the named package.


1 Answers

Try this:

mvn dependency:tree -Dincludes=module

Where module is the dependency you're interested in. You should get the list of libraries that depend on the module you've specified, either directly or transitively.

like image 192
Software Engineer Avatar answered Nov 14 '22 00:11

Software Engineer