You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by br...@apache.org on 2005/05/06 05:57:24 UTC

svn commit: r168513 - in /maven/components/trunk/sandbox/maven-reports/maven-pmd-plugin: ./ pom.xml src/main/java/org/apache/maven/plugin/pmd/PmdReport.java

Author: brett
Date: Thu May  5 20:57:22 2005
New Revision: 168513

URL: http://svn.apache.org/viewcvs?rev=168513&view=rev
Log:
upgrade to PMD 3.0, improve error handling

Modified:
    maven/components/trunk/sandbox/maven-reports/maven-pmd-plugin/   (props changed)
    maven/components/trunk/sandbox/maven-reports/maven-pmd-plugin/pom.xml
    maven/components/trunk/sandbox/maven-reports/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java

Propchange: maven/components/trunk/sandbox/maven-reports/maven-pmd-plugin/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu May  5 20:57:22 2005
@@ -1 +1,4 @@
 target
+*.iml
+*.iws
+*.ipr

Modified: maven/components/trunk/sandbox/maven-reports/maven-pmd-plugin/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/sandbox/maven-reports/maven-pmd-plugin/pom.xml?rev=168513&r1=168512&r2=168513&view=diff
==============================================================================
--- maven/components/trunk/sandbox/maven-reports/maven-pmd-plugin/pom.xml (original)
+++ maven/components/trunk/sandbox/maven-reports/maven-pmd-plugin/pom.xml Thu May  5 20:57:22 2005
@@ -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>

Modified: maven/components/trunk/sandbox/maven-reports/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/sandbox/maven-reports/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java?rev=168513&r1=168512&r2=168513&view=diff
==============================================================================
--- maven/components/trunk/sandbox/maven-reports/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java (original)
+++ maven/components/trunk/sandbox/maven-reports/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/PmdReport.java Thu May  5 20:57:22 2005
@@ -32,7 +32,7 @@
 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 @@
 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
@@ -81,7 +71,7 @@
         {
             sink = getSink();
         }
-        catch( IOException e )
+        catch ( IOException e )
         {
             throw new MavenReportException( "Can't obtain sink for PMD report.", e );
         }
@@ -94,8 +84,8 @@
         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();
 
@@ -104,7 +94,7 @@
         {
             files = getFilesToProcess( "**/*.java", null );
         }
-        catch( IOException e )
+        catch ( IOException e )
         {
             throw new MavenReportException( "Can't parse " + getConfiguration().getSourceDirectory(), e );
         }
@@ -132,7 +122,12 @@
             }
             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
             {
@@ -160,7 +155,7 @@
         StringBuffer excludesStr = new StringBuffer();
         if ( StringUtils.isNotEmpty( excludes ) )
         {
-            excludesStr.append(excludes);
+            excludesStr.append( excludes );
         }
         for ( int i = 0; i < DEFAULT_EXCLUDES.length; i++ )
         {
@@ -171,6 +166,7 @@
             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() );
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org