Does anyone know if it's possible to have single Gradle task for Lint check in the multi-modular Android project? The aim is to have the only one HTML/XML report for all modules (app + a few Android libraries).
Run lint using the standalone tool If you're not using Android Studio or Gradle, you can use the standalone lint tool after you install the Android SDK Command-Line Tools from the SDK Manager. You can then locate the lint tool at android_sdk /cmdline-tools/ version /bin/lint .
The Gradle Lint plugin is a pluggable and configurable linter tool for identifying and reporting on patterns of misuse or deprecations in Gradle scripts and related files.
Integrating In An Existing Codebase Luckily, Android Lint makes it easy to start using lint by providing a baseline. A baseline lets you take a snapshot of your project and then uses the snapshot as a baseline for future inspection runs. To create a baseline add the following in your build. gradle file.
In order to do that configure android lint only in the module where other modules are used as dependencies and enable checkDependencies
in lintOptions
.
ex:
There is an application module called app
which uses feature_1
, feature_2
, feature_3
library modules as dependencies, so set checkDependencies
to true
in lintOptions
of app
module build.gradle
file.
android{
lintOptions{
checkDependencies true // <---
xmlReport false
htmlReport true
htmlOutput file("${project.rootDir}/build/reports/android-lint.html")
}
}
Note:
when you run ./gradlew lint
this will generate reports for every dependency module at each modules build/reports
directory, BUT a report with all lint issues related to the project will be generated at the specified location.
Reference: https://groups.google.com/d/msg/lint-dev/TpTMBMlwPPs/WZHCu59TAwAJ
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With