Search code examples
androidgradlefindbugspmd

Gradle plugins (findbugs, pmd, jdepend, checkstyle) not working


I have the follow app bulild.gradle for my project. When I run the command gradle check no output is reported in the app/build/ folder. I basically used the same code for a previous project and it seemed to work just fine.

apply plugin: 'com.android.application'
apply plugin: "findbugs"
apply plugin: 'pmd'
apply plugin: "jdepend"
apply plugin: 'checkstyle'

findbugs {
    ignoreFailures = false
    effort = "max"
    reportLevel = "low"
}

pmd {
    ignoreFailures = true
}

jdepend{
    ignoreFailures = true
}

tasks.withType(FindBugs) {
    reports {
        xml.enabled = false
        html.enabled = true
    }
}

tasks.withType(Checkstyle) {
    reports {
        xml.enabled false
        html.enabled true
        html.stylesheet resources.text.fromFile('config/xsl/checkstyle-custom.xsl')
    }
}

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"
    defaultConfig {
        applicationId "dat255.refugeeevent"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.google.android.gms:play-services:9.6.1'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:design:24.2.1'
    compile 'com.android.support:support-v4:24.2.1'
    compile 'com.google.code.gson:gson:2.7'
    testCompile 'junit:junit:4.12'
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    compile 'com.github.bumptech.glide:glide:3.5.2'
    compile files ('libs/microsoft-translator-java-api-0.6.2-jar-with-dependencies.jar')
}

Solution

  • Check out gradle fury's quality plugin, works on android and non android projects https://github.com/gradle-fury/gradle-fury. We use it has something to force reports for the site plugin. It's largely based off of work of others with lots of tweaks to make it work correctly for both android and non android projects.

    apply it allprojects { apply from: "https://raw.githubusercontent.com/gradle-fury/gradle-fury/master/gradle/quality.gradle" }

    and then you'll need the contents from here: https://github.com/gradle-fury/gradle-fury/tree/master/config cloned into your repo. Just the config folder, the rest of the stuff isn't needed.

    finally, either call any gradle tasks that requires check. So any one of the following should do the trick

    • gradlew build
    • gradlew check
    • gradlew install (if you're running the maven-support stuff from fury)