[ACCEPTED]-Finding unused jars used in an eclipse project-jar
ClassPathHelper is a good start.
It automatically identifies 5 orphan jars and much more.
The only limitation 4 is with dependencies that are not defined 3 in classes, e.g. in dependency injection 2 framework configuration files.
You also 1 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.
UCDetector does not help for this : It does not work 9 on JARs. And for classpathHelper, I wan't able to find 8 out an easy way just to list the orphan 7 JARs (BTW, if someone has a tutorial for 6 this, i am interested).
So, if you are also 5 using Maven as I do, I find out this great Maven plugin, and I 4 would like to share this solution with you. Just 3 type :
mvn dependency:analyze
And you will instantly get a list 2 of unused JARs in your dependencies. Very 1 handy !
I found a very fast and interesting tool 4 to archive this goal:
Just unzip the program 3 and run:
java -Xmx512m -jar tattletale.jar ~/myjavaproject/mydistribution output
This will generate a very impressive 2 report with different points (text from 1 their site):
- Identify dependencies between JAR files
- Find missing classes from the classpath
- Spot if a class/package is located in multiple JAR files
- Spot if the same JAR file is located in multiple locations
- With a list of what each JAR file requires and provides
- Verify the SerialVersionUID of a class
- Find similar JAR files that have different version numbers
- Find JAR files without a version number
- Find unused JAR archives
- Identify sealed / signed JAR archives
- Locate a class in a JAR file
- Get the OSGi status of your project
- Remove black listed API usage
- And generate the same reports for your .WAR and .EAR archives
I know this is an old one, but if anyone 4 else stumbles upon this, Eclipse does this 3 by itself.
Navigate to Project properties->Java 2 Code Style->Clean Up Select the Eclipse 1 [Built-in] and it does the following:
- Change non static accesses to static members using declaring type
- Change indirect accesses to static members to direct accesses (accesses through subtypes)
- Remove unused imports
- Add missing '@Override' annotations
- Add missing '@Override' annotations to implementations of interface methods
- Add missing '@Deprecated' annotations
- Remove unnecessary casts
- Remove unnecessary '$NON-NLS$' tags
In the Maven and Gradle projects you can 9 use those plugins to identify unused dependencies.
- For Maven : link
Use 8 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 7 give as output. In this case we add commons-collections 6 dependency to pom.xml, but do not use in 5 the code.
- For Gradle : link
Use this in the build.gradle file 4 plugin.
plugins {
id "ca.cutterslade.analyze" version "1.7.1"
}
Using legacy plugin application:
this 3 will give as output. In this case we add 2 dependencies unusedDeclaredArtifacts to 1 gradlefile, but do not use in the code.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.