Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tool to remove unnecessary dependencies in a Java project

I have a Java project that currently has a lot of JARs in its libraries directory, which are all included in the resulting package when building. I know, however, that some of these libs are never referenced in the project.

Is there a tool that can search for libs that are not referenced within the project? I guess there must be something in that sense.

BTW, an Eclipse plugin would be awesome.

EDIT: I chose to go with ClassDep because it was the only suggestion that worked. However, I'm having some trouble with it: please check this question

like image 592
André Chalella Avatar asked Apr 01 '09 20:04

André Chalella


People also ask

How do I remove a project dependencies?

To remove dependencies from projects The Project Dependencies dialog box opens. On the Dependencies tab, select a project from the Project drop-down menu. In the Depends on field, clear the check boxes beside any other projects that are no longer dependencies of this project.

How do you check for unused dependencies in your project?

Using depcheck to Track Dependencies depcheck is a tool that analyzes dependencies by using the information provided by npm inside your React app's package. json file. It helps to identify which npm packages are being utilized in your app and which are not.

How do I clean up my dependencies in IntelliJ?

Before removing a dependency, make sure that it is not used in other modules in the project. To do so, select the necessary dependency and press Alt+F7 . You can also use the Find Usages option of the context menu. or press Alt+Delete .

How do I delete a dependency in Maven?

In Maven, you can use Apache Maven Dependency Plugin, goal dependency:purge-local-repository to remove the project dependencies from the local repository, and re-download it again.


1 Answers

Beware of the case that a class is loaded via Class.forName() and not specified as a dependency in the manifest file (there is a Depends-On: attribute that is for that, but many people don't specify it, which breaks tools like this, the bane of my existence when I worked on such a tool).

like image 85
TofuBeer Avatar answered Oct 02 '22 21:10

TofuBeer