简体   繁体   中英

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.

Just use the mvn dependency:tree command.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM