我想在使用 gradle 构建的企业项目中使用 gradle PMD 插件。
我有一个 pmd_rules.xml
文件已经有效,但我不能添加自己的 java 规则(我得到一个类未找到异常)。我按照它的网站上的教程。
我必须在哪里放置我自己的规则才能让 gradle 和 PMD 识别它们?有人已经做过类似的事情了吗?
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")
}
关于gradle - 使用 Gradle 自定义 PMD 规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26281621/