MrQBerrt
MrQBerrt

Reputation: 1379

Finding unwanted code dependencies on transitive dependencies

I want to find all my Java code dependencies on libraries that I have not included as top level dependencies in Gradle.

My first though as to how to accomplish this is to turn off all transitive dependencies in Gradle and see what compilation errors I get.

From my research the way to do this seems to be:

configurations.all { transitive = false }

Is there a better way, or does this do it?

Upvotes: 0

Views: 98

Answers (1)

Michael Easter
Michael Easter

Reputation: 24468

I'm not sure I understand the question, but the command line "gradle dependencies" might help.

For example, consider this (from this modest project):

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'
}

Using gradle dependencies gives output such as:

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

....

Upvotes: 1

Related Questions