-
-
Notifications
You must be signed in to change notification settings - Fork 140
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, although please note this list is often stale. For a complete list, run ./gradlew tasks --group dependency-analysis.
$ ./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.
$ ./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.
$ ./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.)
This plugin supports the ability to auto-remediate, or auto-fix, the dependency-related issues it finds. It is based on a
simplified grammar capable of parsing the most common Groovy and
Kotlin DSL build script elements; this grammar does stumble over some things, such as if-statements.
$ ./gradlew proj:fixDependencies
Or, for only "safe" fixes:
$ ./gradlew proj:fixDependencies --upgrade
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.
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/.
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).