Skip to content
Tony Robalik edited this page Sep 28, 2020 · 4 revisions

Main tasks

There are several primary tasks intended for use by end-users of the plugin. You may consider them the plugin’s "API", in a manner of speaking. They are listed below.

Build health

$ ./gradlew buildHealth

(or from the Gradle tasks pane in your IDE, under the "dependency-analysis" group)

This task will analyze every subproject (aka "module") in your project, including the root project, for dependency- and plugin-related issues, and produce several reports at build/reports/dependency-analysis/, the main one of which is advice.json. This report is generated in json format because it is intended for machine consumption and post-processing for advanced users. In addition to this main report, there are several others that are more human-readable, in the same directory.

Importantly, this task respects the severity setting, and so may fail if configured to do so.

Project health

$ ./gradlew :proj:projectHealth

projectHealth is the subproject- or module-analogue of buildHealth. It will emit advice for specific projects.

Importantly, this task respects the severity setting, and so may fail if configured to do so.

Reason

$ ./gradlew :proj:reason --id <identifier>

where <identifier> is a module identifier such as :some-proj or com.company:artifact (nb: without a version). You would execute this task to gain additional insight into the reason for some piece of advice. Consider the following example:

You run :proj:projectHealth and see

Existing dependencies which should be modified to be as indicated:
- api(project(":db")) (was implementation)
- api("androidx.appcompat:appcompat:1.1.0-rc01") (was implementation)

You want to understand why you are seeing this advice, so you run

$ ./gradlew :proj:reason --id :db

and you may see something like

> Task :proj:reason
You asked about the dependency :db. You have been advised to change this dependency to api from implementation.

Shortest path to :db from the current project:
:proj
\--- :db

Dependency :db provides the following:
- 15 classes
- 8 public constants

And this dependency is exposed as part of this project's ABI.

Or alternatively, you run

$ ./gradlew proj:reason --id androidx.appcompat:appcompat

with similar output. (Further improvements are planned for this feature.)

Other tasks

For a complete accounting of the tasks used by the plugin, please see source at com.autonomousapps.tasks. Some of the most important ones are listed below.

Importantly, none of these tasks are considered "public API" for this plugin. In particular, they will not respect the severity setting.

AdviceTask

Each subproject in your project will have an instance of AdviceTask added, with names like advice$variantName. For example, adviceDebug, adviceFlavorDebug, and adviceMain (for JVM projects). If you want to run the advice on just a single project, execute

$ ./gradlew some-project:adviceDebug

This will produce several reports at some-project/build/reports/dependency-analysis/debug/.

AbiAnalysisTask

You might be interested in your project’s ABI. If so, you can execute

$ ./gradlew some-project:abiAnalysisDebug

This will produce several reports at some-project/build/reports/dependency-analysis/debug/intermediates/. abi.json is intended for machine use, while abi-dump.txt is a human-readable ABI report. This task is used to help the plugin understand whether some dependency ought to be api or implementation. These reports are in the intermediates/ directory as they are not considered "terminal" reports (cf the advice reports).

Clone this wiki locally