android-check-2

Additional

Language
XSLT
Version
2.244 (Jun 27, 2018)
Created
Oct 27, 2016
Updated
Jun 27, 2018
Owner
Jorge Antonio Díaz-Benito Soriano (stoyicker)
Contributors
stefan-nsk
Jorge Antonio Díaz-Benito Soriano (stoyicker)
2
Activity
Badge
Generate
Download
Source code

Announcement

Android Check 2

Static code analysis plugin for Android projects. This is a fork of the original android-check plugin, which implements a really useful concept, but unfortunately seems abandoned.

Current version tested with Android plugin for Gradle 3.1.3.

Who uses this?

Build status

master

dev

Usage

This plugin is available in the Gradle Plugin Portal and jCenter. It attaches itself to the check task, but you can also execute the corresponding tasks manually when desired: androidCheckstyle for CheckStyle, and androidPmd for PMD.

classpath("org.stoyicker.android-check:plugin:+") {
    // These are to avoid some conflicts due to how classloading is performed by Gradle
    // Only required by Gradle < 4.8: https://github.com/gradle/gradle/issues/5092
    exclude module: "asm"
    exclude module: "gson"
    exclude module: "guava"
    exclude module: "commons-logging"
    // This one is required because Checkstyle and PMD using different Saxon artifacts that have overlapping packages
    // Also only required by Gradle < 4.8: https://github.com/gradle/gradle/issues/5092
    exclude module: "Saxon-HE"
}

Apply the plugin after applying either com.android.application or com.android.library.

apply plugin: "org.stoyicker.android-check"

Configuration

Recommended

The default one.

Customized

// Configuration is completely optional, defaults will be used if not present
check {
  // Do absolutely nothing, default: false
  skip true/false
  // Fails build if a violation is found, default: true
  abortOnError true/false. Ignored if all per-tool confs are set to abortOnError false (see below)
  // Checkstyle configuration
  checkstyle {
    // Completely skip CheckStyle, default: false
    skip true/false

    // Fails build if CheckStyle rule violations are found, default: false
    abortOnError true/false

    // Configuration file for CheckStyle, default: <project_path>/config/checkstyle.xml, if non-existent then <project_path>/<module_path>/config/checkstyle.xml, if non-existent then plugin/src/main/resources/checkstyle/conf-default.xml
    config 'path/to/config.xml'

    // Output file for XML reports, default: new File(project.buildDir, 'outputs/checkstyle/checkstyle.xml')
    reportXML new File(project.buildDir, 'path/where/you/want/checkstyle.xml')

    // Output file for HTML reports, default: new File(project.buildDir, 'outputs/checkstyle/checkstyle.html')
    reportHTML new File(project.buildDir, 'path/where/you/want/checkstyle.html')
  }
  // PMD configuration
  pmd {
    // Completely skip PMD, default: false
    skip true/false

    // Fails build if PMD rule violations are found, default: false
    abortOnError true/false

    // Configuration file for PMD, default: <project_path>/config/pmd.xml, if non-existent then <project_path>/<module_path>/config/pmd.xml, if non-existent then plugin/src/main/resources/pmd/conf-default.xml
    config 'path/to/config.xml'

    // Output file for XML reports, default: new File(project.buildDir, 'outputs/pmd/pmd.xml')
    reportXML new File(project.buildDir, 'path/where/you/want/pmd.xml')
    
    // Output file for HTML reports, default: new File(project.buildDir, 'outputs/pmd/pmd.html')
    reportHTML new File(project.buildDir, 'path/where/you/want/pmd.html')
  }
}

Also, if abortOnError is true, the browser will open the report for the tool that caused the failure (if your system supports it).

Developed By

The original version of this plugin was developed by:

This fork is owned and maintained by Jorge Antonio Diaz-Benito Soriano.

License

See LICENSE.txt.

Original work licensed under MIT license.