Dependency Analysis Gradle Plugin: what fails your build and why
Gradle plugin for JVM projects written in Java, Kotlin, Groovy, or Scala; and Android projects written in Java or Kotlin. Provides advice for managing dependencies and other applied plugins
At a glance
- What is it?
- The Dependency Analysis Gradle Plugin reads compiled classes to decide whether a declared dependency was ever touched, then applies that verdict across a whole multi-project build. Its sharp edges are the module list it refuses to analyse and a setup step that lives in another repository's wiki.
- Who is it for?
- Take the Dependency Analysis Gradle Plugin on if your build is made of Java, Kotlin, Groovy or Scala modules with one of the listed plugins applied, and you want violations to stop CI. Leave it off a build whose modules fall outside that list, because nothing is analysed there and a clean result means less than it looks.
- Can I use it commercially?
- Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 2 days ago.
- What is it written in?
- Mainly Kotlin, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 23, 2026, and from our analysis. They are not legal advice.
Star history
- autonomousapps/dependency-analysis-gradle-plugin2,196 ★ · +16
| Repository | 2026-09-30 | 2026-11-23 |
|---|---|---|
| autonomousapps/dependency-analysis-gradle-plugin | 2.2k | 2.2k |
16 Stars in the last 54 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
The teams this is for: nobody on staff owns the build
The opening line of the project page is a consulting pitch: every team needs a build engineer, but not all teams can afford to have one on staff. That framing sets the audience. Nothing here is a compiler trick aimed at making Gradle faster. The question being answered is whether each line in your build scripts matches what the compiled code actually does.
It answers that question for JVM projects written in Java, Kotlin, Groovy or Scala, and for Android projects written in Java or Kotlin. Nothing else is in scope, which already rules the plugin out for a C++ or Python project that merely uses Gradle for packaging. The analysis combines build and dependency information with evidence from compiled code and other supported inputs; review its findings against how each dependency is actually used.
Four dependency verdicts and two plugin verdicts
The reports split into two families. The dependency family has four members: unused dependencies, used transitive dependencies that you are advised to declare directly, dependencies sitting on the wrong configuration such as `api` versus `implementation` versus `compileOnly`, and unused annotation processors. For these four the plugin offers auto-remediation, so a finding is a diff somebody can accept rather than a note in a file.
The plugin family asks whether a plugin was applied for nothing. Two examples are named: `org.jetbrains.kotlin.jvm` applied but unused, and `com.android.library` applied to a module that could be plain JVM. These are the findings a human reviewer rarely catches on a large build, because the plugin was added years ago for one module and the shape of the project moved on without it.
Four smaller capabilities sit alongside. The plugin warns when a classpath holds duplicate class files. It can trigger the download of external dependencies, which matters for containerized builds that want everything resolvable in one pass. It can print a dominator tree for a project, aimed at finding fat dependencies bloating a deployable. And it can generate a project graph, which is a picture of the build rather than a verdict on it.
Only the listed plugins are analysed, and applications have no api
The most consequential line in the documentation is short: the plugin only analyzes modules with these specific plugins applied. The list is explicit. Android modules use `com.android.application`, `com.android.library`, `com.android.test` or `com.android.kotlin.multiplatform.library`, and for Android the analysis also takes into account whether `org.jetbrains.kotlin.android` has been applied. JVM modules use `java-library` or `org.jetbrains.kotlin.jvm`. Kotlin Multiplatform is covered for the `jvm` and `androidLibrary` targets. `java`, `groovy` and `scala` count only when they also carry an application plugin, or `java-library` in the case of groovy and scala.
A module outside that list is not analysed, and nothing says so. That quietly includes the convenience modules real projects accumulate: a plain Groovy script module, a scratch module, anything assembled without one of those plugins. No configuration key in the documentation widens that coverage.
The second rule is semantic rather than mechanical. The plugin separates libraries from applications: the former have an API, the latter do not. In practical terms, application modules should not carry `api`-like dependencies. A module with `application`, `org.gretty`, `com.google.cloud.tools.jib` or `org.springframework.boot` applied is treated as an application and held to that rule.
Running buildHealth and finding the report on disk
Setup is two files. The settings script declares the plugin id, and the root build script turns every issue into a build failure:
plugins {
id("com.autonomousapps.build-health") version "<<latest_version>>"
}dependencyAnalysis {
issues {
all {
onAny {
severity("fail")
}
}
}
}The version placeholder is meant to be resolved by hand; the badge beside it points at the published artifact on Maven Central. The DSL block applies `severity("fail")` to every issue type, which is what turns the task from a warning into a failure. Then run the task:
./gradlew buildHealthThe documented output on a project with violations is a failure, not a pass: the task reports FAILED and points at `build/reports/dependency-analysis/build-health-report.txt`. That file is where the detail lives, and it is described as potentially very long. To send it to the console instead of hunting for the path, add the reporting block:
dependencyAnalysis {
reporting {
printBuildHealth(true)
}
}Selective analysis with projectHealth and a project-path regex
The instructions above analyse the whole multi-project build. The documentation says plainly that this is not always what you want, and offers three narrower routes.
The first is the `projectHealth` task, which covers one module. The second is applying `com.autonomousapps.dependency-analysis` selectively instead of the build-health plugin, a route the page recommends for very large projects. The third is a Gradle property that filters by project path:
# Include all projects except those whose path begins with `:prefix`
dependency.analysis.project.includes=^((?!:prefix)).*$The value is evaluated as a regex. That example uses a negative lookahead to exclude every project whose path begins with `:prefix` and include everything else, so scoping is written as a pattern over paths rather than as a list of module names.
The genuine alternative is a convention plus a reviewer. Your Gradle files already state what goes on the classpath, and a review rule about `api` versus `implementation` costs nothing to adopt. What that approach cannot produce is evidence, because nothing in the build scripts records whether a declared dependency was ever touched. The plugin's answer is weakest exactly where it was never applied, and partial application makes that boundary deliberate instead of accidental.
central.sonatype.com and the settings classloader caveat
From 2.19.0 for releases, and 2.18.1-SNAPSHOT for snapshots, the plugin publishes through central.sonatype.com. A settings script without a `pluginManagement` block gets the default; a settings script that already has one has to name the right places:
pluginManagement {
repositories {
// releases
mavenCentral()
// snapshots
maven(url = "https://central.sonatype.com/repository/maven-snapshots/")
gradlePluginPortal()
}
}The next paragraph is a warning rather than a footnote: if your project uses Kotlin or Android, or both, those plugins must also be loaded in the settings script classloader, or a parent of it. Miss that and the analysis plugin loads without the types it needs to resolve, and the failure arrives at configuration time rather than at analysis time.
Those two items are why the setup section here is short. The detailed instructions are not on this page at all: they live in the Adding-to-your-project wiki, which is attached to the dependency-analysis-android-gradle-plugin repository rather than to this one. That split is a real cost when you are debugging a first install, and it is worth knowing before you start rather than after.
Failure modes: skipped modules, red builds, console floods
Three failure modes deserve planning. The first is silent coverage, described above: a module without one of the listed plugins yields no findings and no note saying it was skipped, so a clean `buildHealth` run can mean less than it appears.
The second is the DSL block itself. Applying `severity("fail")` to every issue type means the first violation stops the build, which is the right end state and an unpleasant first afternoon on a build with years of drift. The report is written to disk either way, so the fix is to read it before you make the severity blocking.
The third is volume. The report is called potentially very long, and `printBuildHealth(true)` sends all of it to the console, which in CI means a very large log on exactly the run you most want to read.
One boundary is worth stating plainly. Static analysis can miss dynamic or indirect uses such as reflection; check the plugin's current handling of resources and service files before removing dependencies. The README does not document an exemption list for those cases, which is the practical reason to review the report rather than apply the auto-remediation in one pass.
Apache-2.0, three releases in three weeks, and docs in another repo
The licence is Apache-2.0, recorded in LICENSE.txt at the top level, and it places no condition on how you run the analysis or where the reports land.
The release cadence is quick. Three versions arrived inside three weeks: v3.19.0 and v3.19.1 on 2026-08-26, then v3.19.2 on 2026-09-14. The last push was on 2026-09-21. An upgrade is therefore a version bump in `settings.gradle.kts`, plus the settings classloader requirement above if your build uses Kotlin or Android. The top-level layout fits a project that takes its own build seriously: `build-logic/` for convention plugins, separate `api/`, `graph-support/` and `variant-artifacts/` subprojects, `testkit/` for fixtures, and `renovate.json5` to keep dependencies moving.
The cost to plan for is documentation rather than code. This repository's page is README.asciidoc, it stops after the repository setup, and it points outward for everything else. Read the Adding-to-your-project page before you wire the plugin in, because the two documents do not live in the same place.
Editorial conclusion
Take the Dependency Analysis Gradle Plugin on if your build is made of Java, Kotlin, Groovy or Scala modules with one of the listed plugins applied, and you want violations to stop CI. Leave it off a build whose modules fall outside that list, because nothing is analysed there and a clean result means less than it looks. Read the Adding-to-your-project wiki before wiring it in, then run ./gradlew buildHealth once without severity("fail") and read the report before you make it blocking.
Frequently asked questions
What does the Dependency Analysis Gradle Plugin actually check?
It reports unused dependencies, used transitive dependencies you should declare directly, dependencies on the wrong configuration such as api versus implementation versus compileOnly, and unused annotation processors, with auto-remediation for those four. It also flags plugins applied but unused, duplicate class files on a classpath, fat dependencies via a dominator tree, and can generate a project graph.
Which modules does the Dependency Analysis Gradle Plugin analyse?
Only modules with specific plugins applied: com.android.application, com.android.library, com.android.test or com.android.kotlin.multiplatform.library on Android; java-library or org.jetbrains.kotlin.jvm on the JVM; and the Kotlin Multiplatform equivalents for jvm and androidLibrary targets. java, groovy and scala count only alongside an application plugin, or java-library for groovy and scala.
How do I run Dependency Analysis in a Gradle build?
Apply com.autonomousapps.build-health in settings.gradle.kts, add the dependencyAnalysis block to the root build script, then run ./gradlew buildHealth. The report is written to build/reports/dependency-analysis/build-health-report.txt, and printBuildHealth(true) inside a reporting block sends it to the console instead.
Can I run Dependency Analysis on only some of my modules?
Yes. Use the projectHealth task for a single module, apply com.autonomousapps.dependency-analysis selectively instead of the build-health plugin on very large projects, or set the dependency.analysis.project.includes Gradle property to a regex over project paths, for example ^((?!:prefix)).*$ to skip everything under a prefix.
Why does Dependency Analysis fail to configure on a Kotlin or Android project?
The Kotlin and Android plugins must also be loaded in the settings script classloader, or a parent of it, for the analysis plugin to resolve the types it needs. The project points to its Adding-to-your-project wiki for the details of that setup.
Where do I get Dependency Analysis Gradle Plugin snapshots from?
From 2.19.0 for releases and 2.18.1-SNAPSHOT for snapshots, the plugin publishes through central.sonatype.com. Add mavenCentral() for releases and maven(url = "https://central.sonatype.com/repository/maven-snapshots/") inside pluginManagement in settings.gradle.kts.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/autonomousapps-dependency-analysis-gradle-plugin)Star history chart for your README
[](https://hysenlabs.com/projects/autonomousapps-dependency-analysis-gradle-plugin)Was this useful?