Custom PMD rule with Gradle

I would like to use the gradle PMD plugin in an enterprise project which is built with gradle.

I have a pmd_rules.xml file which already works, but I can't add own java rules (I get a class not found exception). I followed the tutorial on it's website.

Where do I have to put my own rules so they get recognized by gradle and PMD? Has somebody already done something like that?

pmd.gradle:

apply from: rootProject.file("core/modules.gradle"), to : ext

if(project.name in (modules["modules"] +modules["modules"])){
    apply plugin: 'pmd'

    pmd {
        ignoreFailures = true
        ruleSetFiles = rootProject.files("../repo/pmd_rules.xml")
        sourceSets = [sourceSets.main,sourceSets.test]
        targetJdk = org.gradle.api.plugins.quality.TargetJdk.VERSION_1_7
        ruleSets = []
        toolVersion = "5.0.5"
    }
}

tasks.withType(Pmd) {
    pmdClasspath += file("path/to/rules.jar")
}
链接地址: http://www.djcxy.com/p/23062.html

上一篇: 运行Pod更新更改Pods生成设置

下一篇: 使用Gradle自定义PMD规则