Saturday, November 29, 2014

Maven: Analyze Dependency

When a Maven project has many dependencies, it is some times difficult to analyze their usage or conflict without appropriate tools. Maven comes with the analyze goal, which allows the user to analyze the dependencies. To run the goal, enter the following command in the terminal after navigating to the project root folder:

> mvn dependency:analyze

As the results printout may be long, therefore a good idea is to save the analysis results into a readable format. To do this, open the pom file of the Maven project and add the following maven-dependency-plugin to the build/plugins section:


Now in the project root folder, run the following command:

> mvn dependency:analyze-report

The command will generate the report in the "target/analyze-report" folder in the project root folder.

Another useful goal is the analyze-duplicate, which checks and reports the duplicated dependencies:

> mvn dependency:analyze-duplicate

To list all dependencies, run the following command:

> mvn dependency:list

To list all the repositories use by the current project, run the following command:

> mvn dependency:list-repositories

To clean the local repository, run the following command:

> mvn dependency:purge-local-repository

No comments:

Post a Comment