January 26, 2016

Gradle Goodness: Getting Information About Buildscript Dependencies

If our build script needs extra dependencies, for example when we add a plugin, then we use a buildscript configuration block and define our dependencies in there. These dependencies are added to a configuration with the name classpath. To see the dependencies and transitive dependencies for the classpath configuration we use the task buildEnvironment. This task is available since Gradle 2.10

Suppose we have the following build file where define the Asciidoctor plugin using the new plugins configuration block. We also add a dependency for PDF generation in the buildscript block:

buildscript {
    dependencies {
        classpath 'org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.8'

plugins {
    id "org.asciidoctor.convert" version "1.5.3"

apply plugin: 'org.asciidoctor.convert'

When we run the buildEnvironment tasks we get an overview of all dependencies:

$ gradle buildEnvironment

Root project

+--- org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.8
|    \--- org.asciidoctor:asciidoctorj:1.5.2
|         +--- org.jruby:jruby-complete:
|         +--- org.slf4j:slf4j-api:1.7.7
|         \--- com.beust:jcommander:1.35
\--- org.asciidoctor:asciidoctor-gradle-plugin:1.5.3


Total time: 7.161 secs

Written with Gradle 2.10.