mirror of https://github.com/apache/maven.git
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:
parent
b8dbe29701
commit
3e936447a5
|
@ -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>
|
||||
|
|
|
@ -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() );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue