How to find/remove unused dependencies in Gradle

后端 未结 6 1022
花落未央
花落未央 2020-11-30 18:28

I wanted to find unused dependencies in my project. Is there a feature for this in Gradle, like in Maven?

6条回答
  •  醉话见心
    2020-11-30 18:42

    Editor's Note: This answer is out of date. Please see the top answer.

    You can try the com.github.nullstress.dependency-analysis Gradle plugin

    Build script snippet for use in all Gradle versions:

    buildscript {
      repositories {
        jcenter()
      }
      dependencies {
        classpath "com.github.nullstress:DependencyAnalysisPlugin:1.0.3"
      }
    }
    
    apply plugin: "com.github.nullstress.dependency-analysis"
    

    Build script snippet for new, incubating, plugin mechanism introduced in Gradle 2.1:

    plugins {
      id "com.github.nullstress.dependency-analysis" version "1.0.3"
    }
    

    Also, there is a thread (Is there a Gradle equivalent of "mvn dependency:analyze"?) in the Gradle forum about this.

提交回复
热议问题