A Gradle plugin to easily apply the same setup of static analysis tools across different Android, Java or Kotlin projects.
Supports Task Configuration Avoidance so that you have zero overhead in build speeds when you use this plugin!
Gradle supports many popular static analysis (Checkstyle, PMD, FindBugs, etc) via a set of built-in plugins. Using these plugins in an Android module will require an additional setup to compensate for the differences between the model adopted by the Android plugin compared to the the Java one.
The gradle-static-analysis-plugin
aims to provide:
- flexible, configurable penalty strategy for builds
- easy, Android-friendly integration for all static analysis
- convenient way of sharing same setup across different projects
- healthy, versionable and configurable defaults
The plugin supports various static analysis tools for Java, Kotlin and Android projects:
Please note that the tools availability depends on the project the plugin is applied to. For more details please refer to the supported tools page.
Spotbugs
#142CPD (Duplicate Code Detection)
[#150](https://github.com/novoda/gradle-static-analysis-plugin/iss (Duplicate Code Detection) ues/150)error-prone
#151Jetbrains IDEA Inspections
#152
For all tools in consideration, please refer to issues.
Android projects use a Gradle model that is not compatible with the Java one, supported by the built-in static analysis tools plugins.
Applying gradle-static-analysis-plugin
to your Android project will make sure all the necessary tasks are created and correctly configured
without any additional hassle.
Apply the plugin from jCenter as a classpath dependency
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.novoda:gradle-static-analysis-plugin:0.8'
}
}
apply plugin: 'com.novoda.static-analysis'
or from the Gradle Plugins Repository:
plugins {
id 'com.novoda.static-analysis' version '0.8'
}
A typical configuration for the plugin will look like:
staticAnalysis {
penalty {
maxErrors = 0
maxWarnings = 0
}
checkstyle { }
pmd { }
findbugs { }
detekt { }
lintOptions { }
}
This will enable all the tools with their default settings. For more advanced configurations, please refer to the advanced usage and to the supported tools pages.
There are two sample Android projects available, one consisting of a regular app - available here - and the other comprising a multi-module setup available here. Both sample projects showcase a setup featuring Checkstyle, FindBugs, PMD, Lint and Detekt.
Snapshot builds from develop
are automatically deployed to a repository that is not synced with JCenter.
To consume a snapshot build add an additional maven repo as follows:
repositories {
maven {
url 'https://dl.bintray.com/novoda-oss/snapshots/'
}
}
You can find the latest snapshot version following this link.
The plugin is under active development and to be considered in beta stage. It is routinely used by many Novoda projects and by other external projects with no known critical issues. The API is supposed to be relatively stable, but there still may be breaking changes as we move towards version 1.0.
Future improvements can be found on the repository's issue tracker.