Displaying Android Gradle dependencies on Jenkins

Android Gradle dependencies

To display Android dependencies in a tree format you need to launch this command:

./gradlew androidDependencies
./gradlew app:dependencies --configuration fastDebugCompileClasspath

HTML dependency report

To display dependencies in html format, add the Project Report plugin to your build.gradle. Here is a code snippet of my project build.gradle to display dependencies for all subprojects (Android modules):

apply plugin: 'project-report'htmlDependencyReport {
projects = project.getSubprojects()
}
./gradlew htmlDependencyReport

Publishing HTML dependency report on Jenkins

Configure a Jenkins project to build html dependencies report and to publish it via HTML Publisher plugin after the build.

Configuring Content Security Policy

Here is the configuration found in the comments on the CSP page which works fine me.

System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "sandbox allow-same-origin allow-scripts; default-src 'self'; script-src * 'unsafe-eval'; img-src *; style-src * 'unsafe-inline'; font-src *")

Dependencies graphs

With gradle-dependency-graph-generator-plugin it’s also possible to visualise library dependencies in graphs. More over you can create a custom generator to filter dependencies by the package name and customise a color of nodes.

apply from: "config/android-graph.gradle"

task generateGraphs {
doLast {
generateDependencyGraph.execute()
generateDependencyGraphAndroidArchLibraries.execute()
generateDependencyGraphFirebaseLibraries.execute()
generateDependencyGraphGoogleGmsLibraries.execute()
generateDependencyGraphGoogleLibraries.execute()
}
}

Publishing graphs on Jenkins

The last thing remains to be done - is to display generated graphs on Jenkins. Image Gallery plugin can be used for this goal. Note, that images you would like to display in the gallery must be archived as artefacts.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store