Can someone tell me how to exclude some interfaces from PMD analysis using maven. I am getting the below exception while making the maven build.
PMD Failure: ILogin$RetrieveLoginInfo_:4 Rule:ConstantsInInterface Priority:3 Avoid constants in interfaces. Interfaces define types, constants are implementation details better placed in classes or enums. See Effective Java, item 19.. [
I have added exclude-pmd.properties in pom's properties. This is my entry in pom.xml properties.
<pmd.excludeFromFailureFile>${project.basedir}/src/etc/exclude-pmd.properties</pmd.excludeFromFailureFile>
exclude-pmd.properties entry:
com.login.ILogin=ConstantsInInterface Priority:3 Avoid constants in interfaces.
Interface:
public interface ILogin {
interface RetrieveLoginInfo_ {
int STATUS=0
}
}
But maven is not exluding ILogin interface from PMD analysis.
Firstly, the structure of your exclude-pmd.properties
is incorrect. As per https://maven.apache.org/plugins/maven-pmd-plugin/examples/violation-exclusions.html
You are expected to use the rule name alone as the value (comma-separated), so in this case it should read:
com.login.ILogin=ConstantsInInterface
That being said, I think you are expecting a different behavior from this property.
This will simply avoid the pmd:check
task from failing if the only violation reported is that one on that file. It will not ignore the file from analysis. It's meant mostly as a way to incrementally enable PMD on a legacy project.
You should probably use a different approach for the use case you describe.