when adding a custom PMD rule set, maven generates an error - net.sourceforge.pmd.RuleSetNotFoundException: Can't find resource rulesets/comments.xml.Make sure the resource is a valid file or URL or is on the CLASSPATH .
For other rule sets, such as basic, naming, etc., it gives no error. But when I add a new set of rules, it throws an error. I also tried <rule ref="rulesets/java/comments.xml/CommentRequired"/> but also gave the same error. comments.xml is already available in the pmd-5.0.2.jar file.
My POM.xml
<dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> <dependency> <groupId>pmd</groupId> <artifactId>pmd</artifactId> <version>5.0.2</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>2.9.1</version> <executions> <execution> <id>attach-javadocs</id> <goals> <goal>jar</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/site/ </outputDirectory> <reportOutputDirectory>${project.reporting.outputDirectory}/site/ </reportOutputDirectory> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-pmd-plugin</artifactId> <version>2.7.1</version> <configuration> <targetjdk>1.6</targetjdk> <skip>fasle</skip> <failOnViolation>false</failOnViolation> <failurePriority>4</failurePriority> <verbose>true</verbose> <rulesets> <ruleset>src/main/resources/rulesets/MyRuleSet.xml</ruleset> </rulesets> </configuration> <executions> <execution> <id>check</id> <goals> <goal>check</goal> </goals> </execution> <execution> <id>cpd-check</id> <goals> <goal>cpd-check</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jxr-plugin</artifactId> <version>2.3</version> </plugin> </plugins> </reporting>
My custom rules file
<?xml version="1.0"?> <ruleset> <rule ref="rulesets/logging-java.xml/SystemPrintln"> <priority>3</priority> </rule> <rule ref="rulesets/naming.xml/VariableNamingConventions"> <priority>3</priority> </rule> <rule ref="rulesets/design.xml/UseSingleton"> <priority>3</priority> </rule> <rule ref="rulesets/controversial.xml/UseConcurrentHashMap"> <priority>3</priority> </rule> <rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"> <priority>3</priority> </rule> <rule ref="rulesets/comments.xml/CommentRequired"> <priority>3</priority> </rule> </ruleset>
Here is my maven stacktrace
INFO]
source share