可以从 PMD/CPD 检查中排除某些来源以防止失败。
<project> ... <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-pmd-plugin</artifactId> <version>3.16.0</version> <executions> <execution> <goals> <goal>check</goal> </goals> <configuration> <excludeFromFailureFile>exclude-pmd.properties</excludeFromFailureFile> </configuration> </execution> <execution> <goals> <goal>cpd-check</goal> </goals> <configuration> <excludeFromFailureFile>exclude-cpd.properties</excludeFromFailureFile> </configuration> </execution> </executions> </plugin> </plugins> </build> ... </project>
对于 cpd 检查,您可以排除不验证的类。可以通过两种方式指定类:
cpd 的属性文件必须具有以下格式:
org.apache.maven.ClassA,org.apache.maven.ClassB org.apache.maven.ClassC org.apache.maven.ClassD
对于 pmd 检查,您可以排除每个类的规则。属性文件必须具有以下格式:
org.apache.maven.ClassA=UnusedPrivateField,EmptyCatchBlock org.apache.maven.ClassB=UnusedPrivateField,UnusedFormalParameter,UnusedPrivateMethod