How to find which dependency is fetching a certain JAR


(dosview) #1

I’m a total novice to Gradle so I hope I can explain this properly.

I work in Eclipse and I build the Java projects through an “External Tool” (menu “Run” / “External tools”) configured to run “gradlew.bat”.

My problem is that whenever I run the build for my Java project, this project ends up having on its build path a certain JAR which I don’t want (“velocity-1.4.jar”). If I manually remove this JAR from the build path, it comes back the next time I run the Gradle build. However the “build.gradle” file I use for building does not mention anything related to Velocity, so I don’t know what to change in order not to fetch that JAR. The file lists several dependencies though, for ex.:

compile (group: 'hsqldb', name: 'hsqldb', version: '1.8.0.10', transitive: false)
 compile (group: 'org.eclipse.jetty', name: 'jetty-distribution', version: '8.1.7.v20120910')
 compile (group: 'commons-lang', name: 'commons-lang',
version: '2.6')
 compile (group: 'org.apache.httpcomponents',name: 'httpclient', version: '4.3.1')

and I imagine that my unwanted JAR comes as a dependency of one of these dependencies. I’m wondering what’s a good way to find out which dependency is fetching the unwanted JAR.


(Olaf Groeger) #2
gradlew.bat dependencies --configuration compile

(Peter Niederwieser) #3

Or:

gradlew dependencyInsight --configuration compile --dependency velocity

(dosview) #4

Thanks. That command actually shows me a big dependency tree (pasted below). But for some reason nothing about Velocity is mentioned there, and yet if I remove the Velocity JARs from the build path entries and then I run that same command with also my build target (that would be

gradlew.bat eclipse dependencies --configuration compile

) those JARs come back, and the same tree that doesn’t mention Velocity is shown. Perhaps I will try to go by exclusion, removing some dependencies from “build.gradle” until the build no longer fetches the Velocity JARs, so I will know which dependency is causing them to be fetched. However I would still like to understand if there is a more proper way to find that out.

D:\svn\MyProject> gradlew.bat eclipse dependencies --configuration compile
:eclipseClasspath
:eclipseJdt
:eclipseProject
:eclipse
:dependencies
  ------------------------------------------------------------
Root project
------------------------------------------------------------
  compile - Compile classpath for source set 'main'.
+--- ch.qos.logback:logback-core:1.0.13
+--- ch.qos.logback:logback-classic:1.0.13
|
  +--- ch.qos.logback:logback-core:1.0.13
|
  \--- org.slf4j:slf4j-api:1.7.5
+--- org.apache.shiro:shiro-core:1.2.2
|
  +--- org.slf4j:slf4j-api:1.6.4 -> 1.7.5
|
  \--- commons-beanutils:commons-beanutils:1.8.3
+--- org.hibernate:hibernate-validator:4.2.0.Final
|
  +--- javax.validation:validation-api:1.0.0.GA -> 1.1.0.Final
|
  \--- org.slf4j:slf4j-api:1.6.1 -> 1.7.5
+--- org.hibernate:hibernate-annotations:3.5.6-Final
|
  +--- org.hibernate:hibernate-core:3.5.6-Final
|
  |
  +--- antlr:antlr:2.7.6 -> 2.7.7
|
  |
  +--- commons-collections:commons-collections:3.1
|
  |
  +--- dom4j:dom4j:1.6.1
|
  |
  |
  \--- xml-apis:xml-apis:1.0.b2
|
  |
  +--- javax.transaction:jta:1.1
|
  |
  \--- org.slf4j:slf4j-api:1.5.8 -> 1.7.5
|
  +--- org.hibernate:hibernate-commons-annotations:3.2.0.Final
|
  |
  \--- org.slf4j:slf4j-api:1.5.8 -> 1.7.5
|
  +--- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.0.Final
|
  \--- org.slf4j:slf4j-api:1.5.8 -> 1.7.5
+--- hsqldb:hsqldb:1.8.0.10
+--- org.eclipse.jetty:jetty-distribution:8.1.7.v20120910
|
  +--- org.eclipse.jetty.orbit:javax.annotation:1.1.0.v201108011116
|
  +--- org.eclipse.jetty.orbit:org.objectweb.asm:3.1.0.v200803061910
|
  +--- org.eclipse.jetty.orbit:javax.activation:1.1.0.v201105071233
|
  +--- org.eclipse.jetty.orbit:javax.mail.glassfish:1.4.1.v201005082020
|
  |
  \--- org.eclipse.jetty.orbit:javax.activation:1.1.0.v201105071233
|
  +--- org.eclipse.jetty.orbit:javax.transaction:1.1.1.v201105210645
|
  +--- org.eclipse.jetty.orbit:javax.security.auth.message:1.0.0.v20110801111
6
|
  +--- org.eclipse.jetty:jetty-jsp:8.1.7.v20120910
|
  |
  +--- org.eclipse.jetty.orbit:javax.servlet.jsp:2.2.0.v201112011158
|
  |
  |
  \--- org.eclipse.jetty.orbit:javax.servlet:3.0.0.v201112011016
|
  |
  +--- org.eclipse.jetty.orbit:org.apache.jasper.glassfish:2.2.2.v201112
011158
|
  |
  |
  +--- org.eclipse.jetty.orbit:javax.servlet:3.0.0.v201112011016
|
  |
  |
  \--- org.eclipse.jetty.orbit:javax.servlet.jsp:2.2.0.v20111201115
8
(*)
|
  |
  +--- org.eclipse.jetty.orbit:javax.servlet.jsp.jstl:1.2.0.v20110521182
1
|
  |
  |
  +--- org.eclipse.jetty.orbit:javax.servlet:2.5.0.v201103041518 ->
 3.0.0.v201112011016
|
  |
  |
  \--- org.eclipse.jetty.orbit:javax.servlet.jsp:2.1.0.v20110521182
0 -> 2.2.0.v201112011158
(*)
|
  |
  +--- org.eclipse.jetty.orbit:org.apache.taglibs.standard.glassfish:1.2
.0.v201112081803
|
  |
  |
  \--- org.eclipse.jetty.orbit:javax.servlet.jsp.jstl:1.2.0.v201105
211821
(*)
|
  |
  +--- org.eclipse.jetty.orbit:javax.el:2.2.0.v201108011116
|
  |
  +--- org.eclipse.jetty.orbit:com.sun.el:2.2.0.v201108011116
|
  |
  \--- org.eclipse.jetty.orbit:org.eclipse.jdt.core:3.7.1
|
  +--- org.eclipse.jetty:jetty-deploy:8.1.7.v20120910
|
  |
  +--- org.eclipse.jetty:jetty-webapp:8.1.7.v20120910
|
  |
  |
  +--- org.eclipse.jetty:jetty-xml:8.1.7.v20120910
|
  |
  |
  |
  \--- org.eclipse.jetty:jetty-util:8.1.7.v20120910
|
  |
  |
  \--- org.eclipse.jetty:jetty-servlet:8.1.7.v20120910
|
  |
  |
       \--- org.eclipse.jetty:jetty-security:8.1.7.v20120910
|
  |
  |
            \--- org.eclipse.jetty:jetty-server:8.1.7.v20120910
|
  |
  |
                 +--- org.eclipse.jetty.orbit:javax.servlet:3.0.0.v
201112011016
|
  |
  |
                 +--- org.eclipse.jetty:jetty-continuation:8.1.7.v2
0120910
|
  |
  |
                 \--- org.eclipse.jetty:jetty-http:8.1.7.v20120910
|
  |
  |
                      \--- org.eclipse.jetty:jetty-io:8.1.7.v201209
10
|
  |
  |
                           \--- org.eclipse.jetty:jetty-util:8.1.7.
v20120910
|
  |
  \--- org.eclipse.jetty:jetty-xml:8.1.7.v20120910 (*)
|
  +--- org.eclipse.jetty:jetty-rewrite:8.1.7.v20120910
|
  |
  +--- org.eclipse.jetty:jetty-server:8.1.7.v20120910 (*)
|
  |
  +--- org.eclipse.jetty:jetty-client:8.1.7.v20120910
|
  |
  |
  \--- org.eclipse.jetty:jetty-http:8.1.7.v20120910 (*)
|
  |
  \--- org.eclipse.jetty.orbit:javax.servlet:3.0.0.v201112011016
|
  +--- org.eclipse.jetty:jetty-ajp:8.1.7.v20120910
|
  |
  \--- org.eclipse.jetty:jetty-server:8.1.7.v20120910 (*)
|
  +--- org.eclipse.jetty:jetty-annotations:8.1.7.v20120910
|
  |
  +--- org.eclipse.jetty:jetty-plus:8.1.7.v20120910
|
  |
  |
  +--- org.eclipse.jetty.orbit:javax.transaction:1.1.1.v20110521064
5
|
  |
  |
  +--- org.eclipse.jetty:jetty-webapp:8.1.7.v20120910 (*)
|
  |
  |
  \--- org.eclipse.jetty:jetty-jndi:8.1.7.v20120910
|
  |
  |
       +--- org.eclipse.jetty:jetty-server:8.1.7.v20120910 (*)
|
  |
  |
       \--- org.eclipse.jetty.orbit:javax.mail.glassfish:1.4.1.v201
005082020
(*)
|
  |
  +--- org.eclipse.jetty:jetty-webapp:8.1.7.v20120910 (*)
|
  |
  +--- org.eclipse.jetty.orbit:javax.annotation:1.1.0.v201108011116
|
  |
  \--- org.eclipse.jetty.orbit:org.objectweb.asm:3.1.0.v200803061910
|
  +--- org.eclipse.jetty:test-jetty-webapp:8.1.7.v20120910
|
  |
  +--- org.eclipse.jetty:jetty-servlets:8.1.7.v20120910
|
  |
  |
  +--- org.eclipse.jetty:jetty-continuation:8.1.7.v20120910
|
  |
  |
  +--- org.eclipse.jetty:jetty-client:8.1.7.v20120910 (*)
|
  |
  |
  \--- org.eclipse.jetty:jetty-util:8.1.7.v20120910
|
  |
  \--- org.eclipse.jetty:jetty-websocket:8.1.7.v20120910
|
  |
       +--- org.eclipse.jetty:jetty-util:8.1.7.v20120910
|
  |
       +--- org.eclipse.jetty:jetty-io:8.1.7.v20120910 (*)
|
  |
       \--- org.eclipse.jetty:jetty-http:8.1.7.v20120910 (*)
|
  +--- org.eclipse.jetty:jetty-jmx:8.1.7.v20120910
|
  |
  \--- org.eclipse.jetty:jetty-util:8.1.7.v20120910
|
  +--- org.eclipse.jetty:jetty-jndi:8.1.7.v20120910 (*)
|
  +--- org.eclipse.jetty:jetty-plus:8.1.7.v20120910 (*)
|
  +--- org.eclipse.jetty:jetty-client:8.1.7.v20120910 (*)
|
  +--- org.eclipse.jetty:jetty-continuation:8.1.7.v20120910
|
  +--- org.eclipse.jetty:jetty-start:8.1.7.v20120910
|
  +--- org.eclipse.jetty:jetty-policy:8.1.7.v20120910
|
  |
  \--- org.eclipse.jetty:jetty-util:8.1.7.v20120910
|
  +--- org.eclipse.jetty:jetty-servlets:8.1.7.v20120910 (*)
|
  +--- org.eclipse.jetty:jetty-monitor:8.1.7.v20120910
|
  |
  +--- org.eclipse.jetty:jetty-util:8.1.7.v20120910
|
  |
  +--- org.eclipse.jetty:jetty-io:8.1.7.v20120910 (*)
|
  |
  +--- org.eclipse.jetty:jetty-http:8.1.7.v20120910 (*)
|
  |
  +--- org.eclipse.jetty:jetty-xml:8.1.7.v20120910 (*)
|
  |
  \--- org.eclipse.jetty:jetty-client:8.1.7.v20120910 (*)
|
  +--- org.eclipse.jetty:jetty-websocket:8.1.7.v20120910 (*)
|
  +--- org.eclipse.jetty:jetty-overlay-deployer:8.1.7.v20120910
|
  |
  +--- org.eclipse.jetty:jetty-deploy:8.1.7.v20120910 (*)
|
  |
  +--- org.eclipse.jetty:jetty-server:8.1.7.v20120910 (*)
|
  |
  \--- org.eclipse.jetty:jetty-plus:8.1.7.v20120910 (*)
|
  \--- org.eclipse.jetty.aggregate:jetty-all:8.1.7.v20120910
|
       \--- org.eclipse.jetty.orbit:javax.servlet:3.0.0.v201112011016
+--- commons-lang:commons-lang:2.6
+--- org.apache.httpcomponents:httpclient:4.3.1
|
  +--- org.apache.httpcomponents:httpcore:4.3
|
  +--- commons-logging:commons-logging:1.1.3
|
  \--- commons-codec:commons-codec:1.6
+--- commons-fileupload:commons-fileupload:1.2 -> 1.2.2
+--- org.apache.tapestry:tapestry-core:5.3.6
|
  +--- org.apache.tapestry:tapestry-json:5.3.6
|
  +--- org.antlr:antlr-runtime:3.3
|
  |
  \--- org.antlr:stringtemplate:3.2.1
|
  |
       \--- antlr:antlr:2.7.7
|
  +--- org.apache.tapestry:tapestry-ioc:5.3.6
|
  |
  +--- org.apache.tapestry:tapestry5-annotations:5.3.6
|
  |
  +--- org.slf4j:slf4j-api:1.6.1 -> 1.7.5
|
  |
  +--- org.apache.tapestry:tapestry-func:5.3.6
|
  |
  +--- javax.inject:javax.inject:1
|
  |
  +--- org.apache.tapestry:plastic:5.3.6
|
  |
  +--- log4j:log4j:1.2.14
|
  |
  \--- javassist:javassist:3.12.1.GA
|
  \--- commons-codec:commons-codec:1.5 -> 1.6
+--- org.apache.tapestry:tapestry-ioc:5.3.6 (*)
+--- org.apache.tapestry:tapestry-json:5.3.6
+--- org.apache.tapestry:tapestry-upload:5.3.6
|
  +--- commons-io:commons-io:2.0.1
|
  +--- commons-fileupload:commons-fileupload:1.2.2
|
  \--- org.apache.tapestry:tapestry-core:5.3.6 (*)
+--- org.apache.tapestry:tapestry-beanvalidator:5.3.6
+--- org.oscy:tapestry-zbreadcrumbs:0.0.2
|
  +--- org.apache.tapestry:tapestry-core:5.3.3 -> 5.3.6 (*)
|
  \--- org.apache.tapestry:tapestry-ioc:5.3.3 -> 5.3.6 (*)
+--- org.got5:tapestry5-jquery:3.3.3
|
  +--- org.apache.tapestry:tapestry-core:5.3.6 (*)
|
  +--- org.apache.tapestry:tapestry-upload:5.3.6 (*)
|
  +--- commons-fileupload:commons-fileupload:1.2.2
|
  \--- commons-lang:commons-lang:2.6
+--- org.apache.tapestry:tapestry-kaptcha:5.3.6
+--- org.tynamo:tapestry-security:0.5.1
|
  +--- org.apache.shiro:shiro-web:1.2.0
|
  +--- org.apache.tapestry:tapestry-core:5.3.4 -> 5.3.6 (*)
|
  +--- org.apache.tapestry:tapestry-ioc:5.3.4 -> 5.3.6 (*)
|
  +--- org.tynamo:tynamo-common:0.0.3
|
  \--- org.tynamo:tapestry-exceptionpage:0.1.2
+--- com.google.code.kaptcha:kaptcha:2.3
\--- javax.validation:validation-api:1.1.0.Final
  (*) - dependencies omitted (listed previously)
  BUILD SUCCESSFUL
  Total time: 6.303 secs

(dosview) #5

This was aimed at the first reply. I’m going to try the second reply. Thanks.


(Peter Niederwieser) #6

If ‘–configuration compile’ doesn’t show the dependency, then it’s probably a ‘runtime’, ‘testCompile’, or ‘testRuntime’ dependency (assuming you are using the standard configurations as declared by the ‘java’ plugin).


(dosview) #7

With the command from the second reply I get this:

D:\svn\MyProject> gradlew dependencyInsight --configuration compile --dependency velocity
:dependencyInsight
No dependencies matching given input were found in configuration ':compile'
  BUILD SUCCESSFUL
  Total time: 5.557 secs

Unfortunately I don’t have enough knowledge to appreciate what it entails that it could be a runtime, testCompile, or testRuntime dependency. I’ll do some more tries.


(Peter Niederwieser) #8

Try with ‘–configuration runtime’ etc.


(Peter Niederwieser) #9

Note that you don’t have to know who brings in Velocity in order to exclude it (although it’s good to know):

configurations.all {
    exclude module: "velocity"
}

(dosview) #10

Thanks everybody, problem solved.

gradlew dependencies --configuration testCompile

did the trick, it was a testCompile dependency:

+--- org.uncommons:reportng:1.1.2
|
  \--- velocity:velocity:1.4
|
       \--- velocity:velocity-dep:1.4

I also learned other important things from the other posts, so now I know what to do next time I have a similar problem. Very good support here, much appreciated.