You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by de...@apache.org on 2008/05/31 21:30:57 UTC

svn commit: r662065 - in /maven/plugins/trunk/maven-checkstyle-plugin: pom.xml src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReportGenerator.java

Author: dennisl
Date: Sat May 31 12:30:56 2008
New Revision: 662065

URL: http://svn.apache.org/viewvc?rev=662065&view=rev
Log:
[MCHECKSTYLE-63] The local absolute path to the headerLocation file is output in the report

Modified:
    maven/plugins/trunk/maven-checkstyle-plugin/pom.xml
    maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java
    maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReportGenerator.java

Modified: maven/plugins/trunk/maven-checkstyle-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/pom.xml?rev=662065&r1=662064&r2=662065&view=diff
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-checkstyle-plugin/pom.xml Sat May 31 12:30:56 2008
@@ -29,7 +29,7 @@
   <name>Maven Checkstyle Plugin</name>
   <version>2.2-SNAPSHOT</version>
   <prerequisites>
-    <maven>2.0.2</maven>
+    <maven>2.0.6</maven>
   </prerequisites>
   <issueManagement>
     <system>JIRA</system>
@@ -131,6 +131,11 @@
       <version>2.0</version>
     </dependency>
     <dependency>
+      <groupId>org.apache.maven.shared</groupId>
+      <artifactId>maven-doxia-tools</artifactId>
+      <version>1.0</version>
+    </dependency>
+    <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-container-default</artifactId>
       <version>1.0-alpha-9</version>
@@ -143,7 +148,7 @@
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
-      <version>1.1</version>
+      <version>1.4.4</version>
     </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>

Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java?rev=662065&r1=662064&r2=662065&view=diff
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java (original)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java Sat May 31 12:30:56 2008
@@ -34,6 +34,7 @@
 import com.puppycrawl.tools.checkstyle.api.SeverityLevel;
 import com.puppycrawl.tools.checkstyle.filters.SuppressionsLoader;
 import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.doxia.tools.SiteTool;
 import org.apache.maven.model.ReportPlugin;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
@@ -75,7 +76,7 @@
 import java.util.ResourceBundle;
 
 /**
- * Perform checkstyle analysis, and generate report on violations.
+ * Perform a Checkstyle analysis, and generate a report on violations.
  *
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
  * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
@@ -318,6 +319,16 @@
     private File useFile;
 
     /**
+     * SiteTool.
+     *
+     * @since 2.2
+     * @component role="org.apache.maven.doxia.tools.SiteTool"
+     * @required
+     * @readonly
+     */
+    protected SiteTool siteTool;
+
+    /**
      * <p>
      * Specifies the location of the suppressions XML file to use.
      * </p>
@@ -719,7 +730,7 @@
     private void generateMainReport( CheckstyleResults results, Configuration config, ModuleFactory moduleFactory,
                                      ResourceBundle bundle )
     {
-        CheckstyleReportGenerator generator = new CheckstyleReportGenerator( getSink(), bundle );
+        CheckstyleReportGenerator generator = new CheckstyleReportGenerator( getSink(), bundle, project.getBasedir(), siteTool );
 
         generator.setLog( getLog() );
         generator.setEnableRulesSummary( enableRulesSummary );

Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReportGenerator.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReportGenerator.java?rev=662065&r1=662064&r2=662065&view=diff
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReportGenerator.java (original)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReportGenerator.java Sat May 31 12:30:56 2008
@@ -24,11 +24,13 @@
 import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
 import com.puppycrawl.tools.checkstyle.api.Configuration;
 import com.puppycrawl.tools.checkstyle.api.SeverityLevel;
+import org.apache.maven.doxia.tools.SiteTool;
 import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.plugin.logging.SystemStreamLog;
 import org.codehaus.doxia.sink.Sink;
 import org.codehaus.plexus.util.StringUtils;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -43,6 +45,8 @@
 {
     private Log log;
 
+    private File basedir;
+
     private ResourceBundle bundle;
 
     private Sink sink;
@@ -61,14 +65,20 @@
 
     private boolean enableRSS;
 
+    private SiteTool siteTool;
+
     private String xrefLocation;
 
-    public CheckstyleReportGenerator( Sink sink, ResourceBundle bundle )
+    public CheckstyleReportGenerator( Sink sink, ResourceBundle bundle, File basedir, SiteTool siteTool )
     {
         this.bundle = bundle;
 
         this.sink = sink;
 
+        this.basedir = basedir;
+
+        this.siteTool = siteTool;
+
         this.enableRulesSummary = true;
         this.enableSeveritySummary = true;
         this.enableFilesSummary = true;
@@ -414,6 +424,24 @@
                         linenum++;
                     }
                 }
+                else if ( "headerFile".equals( name ) && "RegexpHeader".equals( ruleName ) )
+                {
+                    sink.text( ": " );
+                    sink.monospaced();
+                    sink.text( "\"" );
+                    if ( basedir != null )
+                    {
+                        // Make the headerFile value relative to ${basedir}
+                        String path = siteTool.getRelativePath( value, basedir.getAbsolutePath() );
+                        sink.text( path.replace( '\\', '/' ) );
+                    }
+                    else
+                    {
+                        sink.text( value );
+                    }
+                    sink.text( "\"" );
+                    sink.monospaced_();
+                }
                 else
                 {
                     sink.text( ": " );