Hi all
I have a pretty laborious problem: We have an enterprise project which is built with gradle. Gradle includes, among others, the PMD Plugin. Now I need to add a PMD-Rule which checks the source code on specific type references. When I try to add the rule, I get a ClassNotFoundException.
So, where do i have to put the classes so they get recognized by Gradle & PMD? The only way which works so far is to put the class directly into the downloaded PMD dependency jar. But that’s not really an option for production…
So, how do I do that? Where do I have to put my custom rules? How can i tell the plugin where they are found?
Favourite solution would be to pack them as a jar and tell pdm “Here are my rules, take them!”
What I tried so far: * Added a jar with the classes as a local dependency (I’m not sure if it actually found it, there is no error if the path is wrong…) * Put the Class into the PDM library (only way that works) * Put the rule into the projects being built * set the pmdClasspath option. Resulted in other classes not found… * and many rather desperate attempts…
apply from: rootProject.file(“core/modules.gradle”), to : ext
if(project.name in (modules[“CoreModules”] +modules[“Modules”])){
dependencies {
compile files("…/CustomRules/build/libs/CustomRules-1.0.jar")
}
apply plugin: ‘pmd’
pmd {
ignoreFailures = true
ruleSetFiles = rootProject.files("…/repo/auditing/pmd_rules.xml")
sourceSets = [sourceSets.main,sourceSets.test]
targetJdk = org.gradle.api.plugins.quality.TargetJdk.VERSION_1_7
ruleSets = []
toolVersion = “5.0.5”
}
pmdMain {
//pmdClasspath = files("…/repo/lib/pmd-5.1.3.jar")
}