Loading...

November 21, 2009

Gradle Goodness: Display Dependencies for a Gradle Build

We can see the dependencies defined in our project by using the -n or --dependencies argument. We get an overview of the dependencies for each configuration in our Gradle build.

// File: build.gradle
usePlugin 'java'

repositories { 
    mavenCentral() 
}

dependencies {
    compile 'org.springframework:spring-webmvc:2.5.6'
}
$ gradle -n
:reportTask

------------------------------------------------------------
Root Project
------------------------------------------------------------
archives - Configuration for the default artifacts.
compile - Classpath for compiling the sources.
|-----org.springframework:spring-webmvc:2.5.6:default
default - Configuration the default artifacts and its dependencies.
|-----org.springframework:spring-webmvc:2.5.6:default
      |-----org.springframework:spring-beans:2.5.6:master,compile,runtime
      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |-----org.springframework:spring-context:2.5.6:compile,runtime,master
      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----org.springframework:spring-beans:2.5.6:master,compile,runtime
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----aopalliance:aopalliance:1.0:runtime,master,compile
      |-----org.springframework:spring-web:2.5.6:master,runtime,compile
      |      |-----org.springframework:spring-context:2.5.6:compile,runtime,master
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |-----org.springframework:spring-beans:2.5.6:master,compile,runtime
      |      |      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |-----aopalliance:aopalliance:1.0:runtime,master,compile
      |      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----org.springframework:spring-beans:2.5.6:master,compile,runtime
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |-----org.springframework:spring-context-support:2.5.6:compile,runtime,master
      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----org.springframework:spring-beans:2.5.6:master,compile,runtime
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----org.springframework:spring-context:2.5.6:compile,runtime,master
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |-----aopalliance:aopalliance:1.0:runtime,master,compile
      |      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |-----org.springframework:spring-beans:2.5.6:master,compile,runtime
      |      |      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----aopalliance:aopalliance:1.0:runtime,master,compile
      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
runtime - Classpath for running the compiled sources.
|-----org.springframework:spring-webmvc:2.5.6:default
      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |-----org.springframework:spring-context:2.5.6:compile,runtime,master
      |      |-----org.springframework:spring-beans:2.5.6:master,compile,runtime
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----aopalliance:aopalliance:1.0:runtime,master,compile
      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |-----org.springframework:spring-beans:2.5.6:master,compile,runtime
      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |-----org.springframework:spring-context-support:2.5.6:compile,runtime,master
      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----org.springframework:spring-context:2.5.6:compile,runtime,master
      |      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |-----org.springframework:spring-beans:2.5.6:master,compile,runtime
      |      |      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |-----aopalliance:aopalliance:1.0:runtime,master,compile
      |      |-----org.springframework:spring-beans:2.5.6:master,compile,runtime
      |      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----aopalliance:aopalliance:1.0:runtime,master,compile
      |-----org.springframework:spring-web:2.5.6:master,runtime,compile
      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----org.springframework:spring-beans:2.5.6:master,compile,runtime
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----org.springframework:spring-context:2.5.6:compile,runtime,master
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |-----aopalliance:aopalliance:1.0:runtime,master,compile
      |      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |-----org.springframework:spring-beans:2.5.6:master,compile,runtime
      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
testCompile - Classpath for compiling the test sources.
|-----org.springframework:spring-webmvc:2.5.6:default
testRuntime - Classpath for running the test sources.
|-----org.springframework:spring-webmvc:2.5.6:default
      |-----org.springframework:spring-context:2.5.6:compile,runtime,master
      |      |-----aopalliance:aopalliance:1.0:runtime,master,compile
      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----org.springframework:spring-beans:2.5.6:master,compile,runtime
      |      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |-----org.springframework:spring-beans:2.5.6:master,compile,runtime
      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |-----org.springframework:spring-context-support:2.5.6:compile,runtime,master
      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----org.springframework:spring-beans:2.5.6:master,compile,runtime
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----aopalliance:aopalliance:1.0:runtime,master,compile
      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----org.springframework:spring-context:2.5.6:compile,runtime,master
      |      |      |-----org.springframework:spring-beans:2.5.6:master,compile,runtime
      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |-----aopalliance:aopalliance:1.0:runtime,master,compile
      |-----org.springframework:spring-web:2.5.6:master,runtime,compile
      |      |-----org.springframework:spring-beans:2.5.6:master,compile,runtime
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----org.springframework:spring-context:2.5.6:compile,runtime,master
      |      |      |-----org.springframework:spring-beans:2.5.6:master,compile,runtime
      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |-----aopalliance:aopalliance:1.0:runtime,master,compile
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----org.springframework:spring-core:2.5.6:compile,runtime,master
      |      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime
      |      |-----commons-logging:commons-logging:1.1.1:master,compile,runtime

BUILD SUCCESSFUL

Total time: 7.359 secs

Another way is to add the plugin project-reports to our project. We now get the the task dependencyReport in our project. When we run $ gradle dependencyReport we get a text file build/reports/project/dependencies.txt with the same overview of the dependencies.