Gradle 插件(findbugs、pmd、jdepend、checkstyle)不工作

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

我的项目有以下应用程序 bulild.gradle。当我 运行 命令 gradle 检查 app/build/ 文件夹中没有报告输出。我基本上对以前的项目使用了相同的代码,它似乎工作得很好。

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')
}

将以下配置添加到您的 gradle.build 文件中。基本上它不会在您的配置中找到 android 存储库和相关详细信息。

buildscript {

    repositories {
        mavenCentral()
        mavenLocal()
        maven { url 'https://github.com/steffenschaefer/gwt-gradle-plugin/raw/maven-repo/' }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:2.0.0'
    }
}


allprojects {
    repositories {
        jcenter()
    }
}

查看 gradle fury 的质量插件,适用于 android 和非 android 项目 https://github.com/gradle-fury/gradle-fury。我们使用它有一些强制报告站点的插件。它主要基于其他人的工作,并进行了大量调整以使其在 android 和非 android 项目中都能正常工作。

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

然后您需要将此处的内容:https://github.com/gradle-fury/gradle-fury/tree/master/config 克隆到您的存储库中。只需要配置文件夹,其余的东西不需要。

最后,调用任何需要检查的 gradle 任务。所以以下任何一项都可以解决问题

  • gradlew build
  • gradlew check
  • gradlew install(如果你是 运行 来自 fury 的专家支持人员)