【问题标题】:Gradle plugins (findbugs, pmd, jdepend, checkstyle) not workingGradle 插件(findbugs、pmd、jdepend、checkstyle)不工作
【发布时间】:2016-10-12 17:33:23
【问题描述】:

我的项目有以下应用 bulild.gradle。当我运行命令 gradle check 时,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')
}

【问题讨论】:

    标签: android gradle findbugs pmd


    【解决方案1】:

    查看 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(如果你正在运行 maven-support 的狂怒)

    【讨论】:

    • 这个解决方案太棒了
    • 很高兴你喜欢它。我讨厌为了让一些简单的东西可用而需要做很多工作
    • 我完全同意!
    【解决方案2】:

    将以下配置添加到您的 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()
        }
    }
    

    【讨论】:

    • 我建议使用 android studio 并创建一个示例应用程序来启动 android 应用程序。它将创建默认配置,这将使您避免许多不必要的问题
    • 谢谢,我会调查的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-13
    • 2017-07-30
    • 1970-01-01
    • 2012-08-08
    • 1970-01-01
    • 2014-11-11
    相关资源
    最近更新 更多