我正在尝试使用自定义规则集文件运行 PMD,但该规则集包含一个自定义类的规则。此类存在于一个 jar 中,该 jar不是作为依赖项引入的,而是以 zip 文件(这是一个依赖项)的形式出现并被解包。想象一下 PMD 规则类就在build/extralib/blah.jar
.
仅在运行 PMD 时如何将其包含在我的类路径中?我试过了,但没有奏效:
pmd {
ruleSetFiles = files("build/utils/pmd-rules.xml")
pmdClasspath = files("build/extralib")
}
需要明确的是,错误是:java.lang.ClassNotFoundException: com.package.for.pmd.CrazyRule
。运行时会发生这种情况pmdMain
。
第二个问题:Pmd和PmdExtension有什么区别?Pmd 有pmdClasspath
,但 PmdExtension 没有。当我添加pmdClasspath
时,我得到:
Creating properties on demand (a.k.a. dynamic properties) has been deprecated and is scheduled to be removed in Gradle 2.0. Please read http://gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html for information on the replacement for dynamic properties.
Deprecated dynamic property: "pmdClasspath" on "org.gradle.api.plugins.quality.PmdExtension_Decorated@70221fc5", value: "file collection".
所以我猜它只遵守 PmdExtension?作为一个 Gradle 新手,这有点令人困惑......