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> <dependency>
<groupId>pmd</groupId> <groupId>pmd</groupId>
<artifactId>pmd</artifactId> <artifactId>pmd</artifactId>
<version>2.3</version> <version>3.0</version>
</dependency> </dependency>
<!-- TODO: should be in PMD pom -->
<dependency> <dependency>
<groupId>jaxen</groupId> <groupId>jaxen</groupId>
<artifactId>jaxen</artifactId> <artifactId>jaxen</artifactId>

View File

@ -32,7 +32,7 @@ import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.util.Collections; import java.io.InputStream;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -45,33 +45,23 @@ import java.util.List;
public class PmdReport public class PmdReport
extends AbstractMavenReport extends AbstractMavenReport
{ {
protected static final String[] DEFAULT_EXCLUDES = { protected static final String[] DEFAULT_EXCLUDES = {// Miscellaneous typical temporary files
// Miscellaneous typical temporary files "**/*~", "**/#*#", "**/.#*", "**/%*%", "**/._*",
"**/*~",
"**/#*#",
"**/.#*",
"**/%*%",
"**/._*",
// CVS // CVS
"**/CVS", "**/CVS", "**/CVS/**", "**/.cvsignore",
"**/CVS/**",
"**/.cvsignore",
// SCCS // SCCS
"**/SCCS", "**/SCCS", "**/SCCS/**",
"**/SCCS/**",
// Visual SourceSafe // Visual SourceSafe
"**/vssver.scc", "**/vssver.scc",
// Subversion // Subversion
"**/.svn", "**/.svn", "**/.svn/**",
"**/.svn/**",
// Mac // Mac
"**/.DS_Store" "**/.DS_Store"};
};
public void execute() public void execute()
throws MavenReportException throws MavenReportException
@ -94,8 +84,8 @@ public class PmdReport
ruleContext.setReport( report ); ruleContext.setReport( report );
RuleSetFactory ruleSetFactory = new RuleSetFactory(); RuleSetFactory ruleSetFactory = new RuleSetFactory();
RuleSet ruleSet = ruleSetFactory.createRuleSet( InputStream rulesInput = pmd.getClass().getResourceAsStream( "/rulesets/controversial.xml" );
pmd.getClass().getResourceAsStream( "/rulesets/controversial.xml" ) ); RuleSet ruleSet = ruleSetFactory.createRuleSet( rulesInput );
reportSink.beginDocument(); reportSink.beginDocument();
@ -132,7 +122,12 @@ public class PmdReport
} }
catch ( PMDException e ) 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 finally
{ {
@ -171,6 +166,7 @@ public class PmdReport
excludesStr.append( DEFAULT_EXCLUDES[i] ); 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() );
} }
} }