upgrade to PMD 3.0, improve error handling

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@168513 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-05-06 03:57:22 +00:00
parent b8dbe29701
commit 3e936447a5
2 changed files with 22 additions and 25 deletions

View File

@ -29,8 +29,9 @@
<dependency>
<groupId>pmd</groupId>
<artifactId>pmd</artifactId>
<version>2.3</version>
<version>3.0</version>
</dependency>
<!-- TODO: should be in PMD pom -->
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>

View File

@ -32,7 +32,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Collections;
import java.io.InputStream;
import java.util.Iterator;
import java.util.List;
@ -45,33 +45,23 @@ import java.util.List;
public class PmdReport
extends AbstractMavenReport
{
protected static final String[] DEFAULT_EXCLUDES = {
// Miscellaneous typical temporary files
"**/*~",
"**/#*#",
"**/.#*",
"**/%*%",
"**/._*",
protected static final String[] DEFAULT_EXCLUDES = {// Miscellaneous typical temporary files
"**/*~", "**/#*#", "**/.#*", "**/%*%", "**/._*",
// CVS
"**/CVS",
"**/CVS/**",
"**/.cvsignore",
"**/CVS", "**/CVS/**", "**/.cvsignore",
// SCCS
"**/SCCS",
"**/SCCS/**",
"**/SCCS", "**/SCCS/**",
// Visual SourceSafe
"**/vssver.scc",
// Subversion
"**/.svn",
"**/.svn/**",
"**/.svn", "**/.svn/**",
// Mac
"**/.DS_Store"
};
"**/.DS_Store"};
public void execute()
throws MavenReportException
@ -94,8 +84,8 @@ public class PmdReport
ruleContext.setReport( report );
RuleSetFactory ruleSetFactory = new RuleSetFactory();
RuleSet ruleSet = ruleSetFactory.createRuleSet(
pmd.getClass().getResourceAsStream( "/rulesets/controversial.xml" ) );
InputStream rulesInput = pmd.getClass().getResourceAsStream( "/rulesets/controversial.xml" );
RuleSet ruleSet = ruleSetFactory.createRuleSet( rulesInput );
reportSink.beginDocument();
@ -132,7 +122,12 @@ public class PmdReport
}
catch ( PMDException e )
{
throw new MavenReportException( "Failure executing PMD for: " + file, e );
Exception ex = e;
if ( e.getReason() != null )
{
ex = e.getReason();
}
throw new MavenReportException( "Failure executing PMD for: " + file, ex );
}
finally
{
@ -171,6 +166,7 @@ public class PmdReport
excludesStr.append( DEFAULT_EXCLUDES[i] );
}
return FileUtils.getFiles( new File( getConfiguration().getSourceDirectory() ), includes, excludesStr.toString() );
return FileUtils.getFiles( new File( getConfiguration().getSourceDirectory() ), includes,
excludesStr.toString() );
}
}