Look into using the Maven Dependency Plugin to analyze project dependencies
The main goal here is to start a discussion around eliminating the import of duplicate/unused jar
files into our projects. Most of our Java projects import the common-core
and common-test
packages, which contain many of the same dependencies that are usually re-declared in the project pom.xml
file. Removing these imports should ultimately be a net-positive for our projects since the pom.xml
file will be easier to manage and the desired dependency versions will be normalized across all projects.
Maven supports dependency analysis out of the box. It's as simple as running mvn dependency:analyze
or any of the commands listed here: https://maven.apache.org/plugins/maven-dependency-plugin/
mvn dependency:analyze
analyzes the dependencies of this project and determines which are: used and declared; used and undeclared; unused and declared.
At the very least, we should resolve conflicts in the unused and declared
category. We can even add conditions stop a build from passing if there are dependency warnings in our project.
ex: Seen in the image below: running mvn dependency:analyze
on the working-groups-api
. Many of the dependencies declared in the project's pom are already included in 0.7.0
of api-commons
, creating unused dependencies. All of these can be removed without any impact on the functionality of the service.