Finding unused jars used in an eclipse project

Viewed 55217

Are there any plugins/tools available to go through the classpath of an eclipse project (or workspace) and highlight any unused jars?

6 Answers

ClassPathHelper is a good start.

It automatically identifies orphan jars and much more.

The only limitation is with dependencies that are not defined in classes, e.g. in dependency injection framework configuration files.

You also have other options/complements, such as:

  • workingfrog "Relief", which relies on the ability to deal with real objects by examining their shape, size or relative place in space it gives a "physical" view on java packages, types and fields and their relationships, making them easier to handle.
  • Unnecessary Code Detector: a eclipse PlugIn tool to find unnecessary (dead) public java code.

In the Maven and Gradle projects you can use those plugins to identify unused dependencies.

Use this in the pom.xml file plugin.

<build>
<plugins>
    <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>3.1.2</version>
    </plugin>
</plugins>
</build>

this will give as output. In this case we add commons-collections dependency to pom.xml, but do not use in the code. enter image description here

Use this in the build.gradle file plugin.

plugins {
  id "ca.cutterslade.analyze" version "1.7.1"
}

Using legacy plugin application:

enter image description here

this will give as output. In this case we add dependencies unusedDeclaredArtifacts to gradlefile, but do not use in the code. enter image description here

Related