wood burning stoves
The moose likes Ant, Maven and Other Build Tools and the fly likes Maven PMD Error with ruleset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Maven PMD Error with ruleset" Watch "Maven PMD Error with ruleset" New topic

Maven PMD Error with ruleset


Joined: Jan 06, 2007
Posts: 6

I have a Maven WebApp project (Just a HelloWorld Servlet) in Eclipse and running tomcat server. My ultimate aim is to fail the build if the code contains out.print statements. I have defined the maven pmd plugin 2.5 in the pom.xml as below and defined a customized ruleset in a file called sop.xml as below.

But when I right click the project -> Run As -> Maven Build and try to package,it is throwing an error as follows,

"Failed to execute goal org.apache.maven.plugins:maven-pmd-plugin:2.5:pmd (pmd) on project MavenWebArtifactId: An error has occurred in PMD Report report generation. Could not find resource 'c:\rulesets\sop.xml'".

I am new to Maven and requesting all your kind help on this regard. Thanks.


<?xml version="1.0"?>
<ruleset name="Custom ruleset"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd"
<description>This ruleset checks my code for println statements</description>
<rule ref="rulesets/JavaLogging.xml" message="Must handle exceptions"> </rule>


<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17281

Chances are that your ruleset path is invalid and it's reading "C:\rulesets\sop.xml" as being relative to the project, not relative to the root of the C drive (helpful hint: in Java, usually using Unix-style paths works better).

Maven doesn't like to pull resources from locations outside of the project directory tree (not counting the download/cache mechanism). That's because in theory every Maven project can be collapsed with a "mvn clean" command, zipped, sent to (or from!) Ulan Bator, installed on another machine and completely rebuilt with a single Maven command. You can't do that if there are things that are dependent on the original machine's filesystem layout.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link: http://aspose.com/file-tools
subject: Maven PMD Error with ruleset
It's not a secret anymore!