Is there a way to tell pmd to exclude specific srcDirs from a sourceSet?
I have a project that uses Axis to generate wsdl and xsd java source.
To allow for the incremental build, we put the generated files into two folders
$buildDir/generated-xsd
$buildDir/generated-wsdl
We then add those two directories to the java source sets.
I would like for PMD to run only on the non generated source. I have added this pmd block to build.gradle but it is impacting the java compile as well.
sourceSets {
main {
java {
srcDirs "$project.buildDir/generated-xsd", "$project.buildDir/generated-wsdl"
}
}
}
pmd {
sourceSets {
main {
java {
//Exclude generated sources
srcDirs = srcDirs - (files("${buildDir}/generated-xsd") + files("${buildDir}/generated-wsdl"))
}
}
}
}//end pmd
task timTest {
doLast {
project.pmd.sourceSets.main.java.srcDirs.each {println it}
project.sourceSets.main.java.srcDirs.each {println it}
}
}
I can’t use the PMD excludes as that uses name spaces and there isn’t a specific naming standard in that generated code that I can easily use to sepearate it out from the original java source.
When I execute my timTest task I was surprised to see that the pmd source set modified the project sourceSet. I would have expected PMD to have it’s own sourceSet.