查找传递依赖项上不需要的代码依赖项



我想在库上找到我所有的 Java 代码依赖项,这些依赖项未作为顶级依赖项包含在 Gradle 中。

关于如何做到这一点,我的第一个方法是关闭 Gradle 中的所有传递依赖项,看看我遇到了哪些编译错误。

根据我的研究,这样做的方法似乎是:

configurations.all { transitive = false }

有没有更好的方法,或者这样做吗?

我不确定我是否理解这个问题,但命令行" gradle dependencies "可能会有所帮助。

例如,考虑一下(来自这个适度的项目):

dependencies {
    groovy 'org.codehaus.groovy:groovy-all:1.6.4'
    groovy 'com.google.guava:guava-collections:r03'
    releaseJars 'org.codehaus.groovy:groovy-all:1.6.4'
    releaseJars 'com.google.guava:guava-collections:r03'
}

使用 gradle dependencies 会给出如下输出:

compile - Classpath for compiling the main sources.
+--- org.codehaus.groovy:groovy-all:1.6.4
|    +--- junit:junit:3.8.2
|    +--- org.apache.ant:ant:1.7.1
|    |    --- org.apache.ant:ant-launcher:1.7.1
|    +--- org.apache.ant:ant-launcher:1.7.1
|    --- jline:jline:0.9.94
|         --- junit:junit:3.8.1 -> 3.8.2
--- com.google.guava:guava-collections:r03
     +--- com.google.guava:guava-annotations:r03
     --- com.google.guava:guava-primitives:r03
....

最新更新