Finding unused jars used in an eclipse project

前端 未结 5 713
情歌与酒
情歌与酒 2020-11-28 02:52

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

相关标签:
5条回答
  • 2020-11-28 03:20

    I know this is an old one, but if anyone else stumbles upon this, Eclipse does this by itself.

    Navigate to Project properties->Java Code Style->Clean Up Select the Eclipse [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
    0 讨论(0)
  • 2020-11-28 03:23

    UCDetector does not help for this : It does not work on JARs. And for classpathHelper, I wan't able to find out an easy way just to list the orphan JARs (BTW, if someone has a tutorial for this, i am interested).

    So, if you are also using Maven as I do, I find out this great Maven plugin, and I would like to share this solution with you. Just type :

    mvn dependency:analyze
    

    And you will instantly get a list of unused JARs in your dependencies. Very handy !

    0 讨论(0)
  • 2020-11-28 03:26

    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.
    0 讨论(0)
  • 2020-11-28 03:28

    You can use one of this plugins: UCDetector or Classpath Helper

    0 讨论(0)
  • 2020-11-28 03:36

    I found a very fast and interesting tool to archive this goal:

    http://tattletale.jboss.org/

    Just unzip the program and run:

    java -Xmx512m -jar tattletale.jar ~/myjavaproject/mydistribution output
    

    This will generate a very impressive report with different points (text from 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
    0 讨论(0)
提交回复
热议问题