Skip to content
Tony Robalik edited this page May 24, 2020 · 8 revisions

Detailed guidance on how to use, and get the most out of, the Dependency Analysis Plugin.

Use Cases

We’ll get started with the primary use-cases the plugin supports. This plugin will tell you the following about your project:

  1. Unused dependencies which should be removed.

  2. Declared dependencies which are on the wrong configuration (api vs implementation vs compileOnly). This is variant-aware, so it might tell you to use debugImplementation, for example.

  3. Transitively used dependencies which ought to be declared directly, and on which configuration.

  4. Dependencies which could be declared on the compileOnly configuration, as they’re not required at runtime.

  5. Annotation processors which could be removed as unused.

  6. Plugins that are applied but which can be removed.

This 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):

  1. Dependency (identifier, resolved version, and declared configuration, if any)

  2. "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.

  3. "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

  1. usedTransitiveDependencies: Set<Dependency> for transitive dependencies that are used.

  2. parents: Set<Dependency> for unused dependencies that contribute this transitive dependency.

Clone this wiki locally