bewithaman
bewithaman

Reputation: 778

Get all 3rd Party dependencies module is using in Maven

We have a multi-module maven project. I have a use case where I want to know to get a list of all the dependencies which is being used in code with version:

  1. If its declared in pom and being used.
  2. Not declared in pom but still being used (transitively imported).

Bonus would be if the approach can exclude the deps which are being declared in pom but not being used in the code.

Please suggest the best way to achieve this. TIA.

Upvotes: 1

Views: 1090

Answers (2)

Gerold Broser
Gerold Broser

Reputation: 14762

There's the Maven Dependency Plugin:

The dependency plugin provides the capability to manipulate artifacts. It can copy and/or unpack artifacts from local or remote repositories to a specified location.

with its tree goal:

Displays the dependency tree for this project.

Regarding your bonus there's the analyze goal:

analyzes the dependencies of this project and determines which are: used and declared; used and undeclared; unused and declared.

and the analyze-only goal:

is the same as analyze, but is meant to be bound in a pom. It does not fork the build and execute test-compile.

Upvotes: 2

Tobias Miosczka
Tobias Miosczka

Reputation: 213

Just use the mvn dependency:tree command.

Upvotes: 2

Related Questions