-
-
Notifications
You must be signed in to change notification settings - Fork 124
Home
Detailed guidance on how to use, and get the most out of, the Dependency Analysis Plugin.
-
You’re a library author and want to correctly declare your dependencies as
api
vsimplementation
so that users can easily consume your library. -
You maintain a project with a lot of dependencies and want to have control over and understanding of them. You want to insulate yourself from libraries changing their transitive dependencies in a way that would break your project.
-
You maintain a very large project with a huge number of dependencies and it’s basically impossible to know what you actually use anymore, particularly as your team grows in size. You also want to break inter-project dependencies to enable more parallel compilation.
The plugin enables these use-cases through the concept of "advice". When you execute the buildHealth
task, it analyzes your entire project, including all variants for Android projects, and does two things:
. Prints that advice to the console in an easy-to-read format.
. Prints that advice to disk as JSON for advanced users who want to automate post-processing the results.
The advice comes in the following flavors:
-
Unused dependencies which should be removed.
-
Declared dependencies which are on the wrong configuration (
api
vsimplementation
vscompileOnly
). This is variant-aware, so it might tell you to usedebugImplementation
, for example. -
Transitively used dependencies which ought to be declared directly, and on which configuration.
-
Dependencies which could be declared on the
compileOnly
configuration, as they’re not required at runtime. -
Annotation processors which could be removed as unused.
-
Plugins that are applied but which can be removed. (currently we support kapt, java-library, and kotlin-jvm for redundancy-checking)
As mentioned, the advice is printed to console in a narrative form, and also written to disk as JSON. The JSON output has several components (see the com.autonomousapps.advice.Advice
model class):
-
Dependency (identifier, resolved version, and declared configuration, if any)
-
"fromConfiguration", which is the configuration on which the dependency is currently declared. Typically "api" or "implementation". If this field is not present, that means it is null and the dependency is transitive. It should be declared directly.
-
"toConfiguration", which is the configuration on which the dependency should be declared. If this field is not present, that means it is null and the dependency should be removed.
Additionally, the Advice
class includes
-
usedTransitiveDependencies: Set<Dependency>
for transitive dependencies that are used. -
parents: Set<Dependency>
for unused dependencies that contribute this transitive dependency.