You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2011/10/01 23:55:27 UTC

svn commit: r1178094 - in /maven/plugins/trunk/maven-checkstyle-plugin/src: it/minimal-pom/ main/java/org/apache/maven/plugin/checkstyle/ main/resources/config/ test/java/org/apache/maven/plugin/checkstyle/ test/java/org/apache/maven/plugin/checkstyle/...

Author: olamy
Date: Sat Oct  1 21:55:26 2011
New Revision: 1178094

URL: http://svn.apache.org/viewvc?rev=1178094&view=rev
Log:
[MCHECKSTYLE-62] Support aggregated reports in a multi-modules project
Submitted by Antonio Petrelli.

Added:
    maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/AbstractCheckstyleReport.java   (with props)
    maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleAggregateReport.java   (with props)
    maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/CheckstyleAggregateReportTest.java   (with props)
    maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/stubs/ModuleMavenProjectStub.java   (with props)
    maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/stubs/MultiMavenProjectStub.java   (with props)
    maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/multi-plugin-config.xml   (with props)
Modified:
    maven/plugins/trunk/maven-checkstyle-plugin/src/it/minimal-pom/verify.bsh
    maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleExecutorRequest.java
    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/CheckstyleReportListener.java
    maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/DefaultCheckstyleExecutor.java
    maven/plugins/trunk/maven-checkstyle-plugin/src/main/resources/config/maven_checks.xml

Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/it/minimal-pom/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/it/minimal-pom/verify.bsh?rev=1178094&r1=1178093&r2=1178094&view=diff
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/it/minimal-pom/verify.bsh (original)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/it/minimal-pom/verify.bsh Sat Oct  1 21:55:26 2011
@@ -32,7 +32,7 @@ try
         return false;
     }
 
-    String[] reports = { "checkstyle" };
+    String[] reports = { "checkstyle", "checkstyle-aggregate" };
     for ( String report : reports )
     {
         File reportFile = new File( siteDir, report + ".html" );

Added: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/AbstractCheckstyleReport.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/AbstractCheckstyleReport.java?rev=1178094&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/AbstractCheckstyleReport.java (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/AbstractCheckstyleReport.java Sat Oct  1 21:55:26 2011
@@ -0,0 +1,475 @@
+package org.apache.maven.plugin.checkstyle;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Calendar;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.apache.maven.doxia.siterenderer.Renderer;
+import org.apache.maven.doxia.tools.SiteTool;
+import org.apache.maven.model.ReportPlugin;
+import org.apache.maven.plugin.checkstyle.rss.CheckstyleRssGenerator;
+import org.apache.maven.plugin.checkstyle.rss.CheckstyleRssGeneratorRequest;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.reporting.AbstractMavenReport;
+import org.apache.maven.reporting.MavenReportException;
+import org.codehaus.plexus.resource.ResourceManager;
+import org.codehaus.plexus.resource.loader.FileResourceLoader;
+import org.codehaus.plexus.util.PathTool;
+import org.codehaus.plexus.util.StringUtils;
+
+import com.puppycrawl.tools.checkstyle.DefaultLogger;
+import com.puppycrawl.tools.checkstyle.XMLLogger;
+import com.puppycrawl.tools.checkstyle.api.AuditListener;
+import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
+
+/**
+ * Base abstract class for Checkstyle reports.
+ *
+ * @version $Id: CheckstyleReport.java 1155028 2011-08-08 17:53:46Z olamy $
+ * @since 2.8
+ */
+public abstract class AbstractCheckstyleReport
+    extends AbstractMavenReport
+{
+    public static final String PLUGIN_RESOURCES = "org/apache/maven/plugin/checkstyle";
+
+    /**
+     * Skip entire check.
+     *
+     * @parameter expression="${checkstyle.skip}" default-value="false"
+     * @since 2.2
+     */
+    protected boolean skip;
+
+    /**
+     * The output directory for the report. Note that this parameter is only
+     * evaluated if the goal is run directly from the command line. If the goal
+     * is run indirectly as part of a site generation, the output directory
+     * configured in Maven Site Plugin is used instead.
+     *
+     * @parameter default-value="${project.reporting.outputDirectory}"
+     * @required
+     */
+    private File outputDirectory;
+
+    /**
+     * Specifies the path and filename to save the checkstyle output. The format
+     * of the output file is determined by the <code>outputFileFormat</code>
+     * parameter.
+     *
+     * @parameter expression="${checkstyle.output.file}"
+     *            default-value="${project.build.directory}/checkstyle-result.xml"
+     */
+    private File outputFile;
+
+    /**
+     * If <code>null</code>, the Checkstyle plugin will display violations on stdout.
+     * Otherwise, a text file will be created with the violations.
+     *
+     * @parameter
+     */
+    private File useFile;
+
+    /**
+     * Specifies the format of the output to be used when writing to the output
+     * file. Valid values are "plain" and "xml".
+     *
+     * @parameter expression="${checkstyle.output.format}" default-value="xml"
+     */
+    private String outputFileFormat;
+
+    /**
+     * Specifies if the Rules summary should be enabled or not.
+     *
+     * @parameter expression="${checkstyle.enable.rules.summary}"
+     *            default-value="true"
+     */
+    private boolean enableRulesSummary;
+
+    /**
+     * Specifies if the Severity summary should be enabled or not.
+     *
+     * @parameter expression="${checkstyle.enable.severity.summary}"
+     *            default-value="true"
+     */
+    private boolean enableSeveritySummary;
+
+    /**
+     * Specifies if the Files summary should be enabled or not.
+     *
+     * @parameter expression="${checkstyle.enable.files.summary}"
+     *            default-value="true"
+     */
+    private boolean enableFilesSummary;
+
+    /**
+     * Specifies if the RSS should be enabled or not.
+     *
+     * @parameter expression="${checkstyle.enable.rss}" default-value="true"
+     */
+    private boolean enableRSS;
+
+    /**
+     * SiteTool.
+     *
+     * @since 2.2
+     * @component role="org.apache.maven.doxia.tools.SiteTool"
+     * @required
+     * @readonly
+     */
+    protected SiteTool siteTool;
+
+    /**
+     * The Maven Project Object.
+     *
+     * @parameter default-value="${project}"
+     * @required
+     * @readonly
+     */
+    protected MavenProject project;
+
+    /**
+     * Link the violation line numbers to the source xref. Will link
+     * automatically if Maven JXR plugin is being used.
+     *
+     * @parameter expression="${linkXRef}" default-value="true"
+     * @since 2.1
+     */
+    private boolean linkXRef;
+
+    /**
+     * Location of the Xrefs to link to.
+     *
+     * @parameter default-value="${project.reporting.outputDirectory}/xref"
+     */
+    private File xrefLocation;
+
+    /**
+     * @component
+     * @required
+     * @readonly
+     */
+    private Renderer siteRenderer;
+
+    /**
+     * @component
+     * @required
+     * @readonly
+     */
+    protected ResourceManager locator;
+
+    /**
+     * CheckstyleRssGenerator.
+     *
+     * @since 2.4
+     * @component role="org.apache.maven.plugin.checkstyle.rss.CheckstyleRssGenerator" role-hint="default"
+     * @required
+     * @readonly
+     */
+    protected CheckstyleRssGenerator checkstyleRssGenerator;
+
+    /**
+     * @since 2.5
+     * @component role="org.apache.maven.plugin.checkstyle.CheckstyleExecutor" role-hint="default"
+     * @required
+     * @readonly
+     */
+    protected CheckstyleExecutor checkstyleExecutor;
+
+    protected ByteArrayOutputStream stringOutputStream;
+
+    /** {@inheritDoc} */
+    public String getName( Locale locale )
+    {
+        return getBundle( locale ).getString( "report.checkstyle.name" );
+    }
+
+    /** {@inheritDoc} */
+    public String getDescription( Locale locale )
+    {
+        return getBundle( locale ).getString( "report.checkstyle.description" );
+    }
+
+    /** {@inheritDoc} */
+    protected String getOutputDirectory()
+    {
+        return outputDirectory.getAbsolutePath();
+    }
+
+    /** {@inheritDoc} */
+    protected MavenProject getProject()
+    {
+        return project;
+    }
+
+    /** {@inheritDoc} */
+    protected Renderer getSiteRenderer()
+    {
+        return siteRenderer;
+    }
+
+    /** {@inheritDoc} */
+    public void executeReport( Locale locale )
+        throws MavenReportException
+    {
+        locator.addSearchPath( FileResourceLoader.ID, project.getFile().getParentFile().getAbsolutePath() );
+        locator.addSearchPath( "url", "" );
+
+        locator.setOutputDirectory( new File( project.getBuild().getDirectory() ) );
+
+        // for when we start using maven-shared-io and
+        // maven-shared-monitor...
+        // locator = new Locator( new MojoLogMonitorAdaptor( getLog() ) );
+
+        // locator = new Locator( getLog(), new File(
+        // project.getBuild().getDirectory() ) );
+
+        ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
+
+        try
+        {
+            CheckstyleExecutorRequest request = createRequest();
+
+            CheckstyleResults results = checkstyleExecutor.executeCheckstyle( request );
+
+            ResourceBundle bundle = getBundle( locale );
+            generateReportStatics();
+            generateMainReport( results, bundle );
+            if ( enableRSS )
+            {
+                CheckstyleRssGeneratorRequest checkstyleRssGeneratorRequest =
+                    new CheckstyleRssGeneratorRequest( this.project, this.getCopyright(), outputDirectory, getLog() );
+                checkstyleRssGenerator.generateRSS( results, checkstyleRssGeneratorRequest );
+            }
+
+        }
+        catch ( CheckstyleException e )
+        {
+            throw new MavenReportException( "Failed during checkstyle configuration", e );
+        }
+        catch ( CheckstyleExecutorException e )
+        {
+            throw new MavenReportException( "Failed during checkstyle execution", e );
+        }
+        finally
+        {
+            //be sure to restore original context classloader
+            Thread.currentThread().setContextClassLoader( currentClassLoader );
+        }
+    }
+
+    /**
+     * Create the Checkstyle executor request.
+     *
+     * @return The executor request.
+     * @throws MavenReportException If something goes wrong during creation.
+     */
+    protected abstract CheckstyleExecutorRequest createRequest()
+            throws MavenReportException;
+
+    /**
+     * Creates and returns the report generation listener.
+     *
+     * @return The audit listener.
+     * @throws MavenReportException If something goes wrong.
+     */
+    protected AuditListener getListener()
+        throws MavenReportException
+    {
+        AuditListener listener = null;
+
+        if ( StringUtils.isNotEmpty( outputFileFormat ) )
+        {
+            File resultFile = outputFile;
+
+            OutputStream out = getOutputStream( resultFile );
+
+            if ( "xml".equals( outputFileFormat ) )
+            {
+                listener = new XMLLogger( out, true );
+            }
+            else if ( "plain".equals( outputFileFormat ) )
+            {
+                listener = new DefaultLogger( out, true );
+            }
+            else
+            {
+                // TODO: failure if not a report
+                throw new MavenReportException( "Invalid output file format: (" + outputFileFormat
+                    + "). Must be 'plain' or 'xml'." );
+            }
+        }
+
+        return listener;
+    }
+
+    private OutputStream getOutputStream( File file )
+        throws MavenReportException
+    {
+        File parentFile = file.getAbsoluteFile().getParentFile();
+
+        if ( !parentFile.exists() )
+        {
+            parentFile.mkdirs();
+        }
+
+        FileOutputStream fileOutputStream;
+        try
+        {
+            fileOutputStream = new FileOutputStream( file );
+        }
+        catch ( FileNotFoundException e )
+        {
+            throw new MavenReportException( "Unable to create output stream: " + file, e );
+        }
+        return fileOutputStream;
+    }
+
+    /**
+     * Creates and returns the console listener.
+     *
+     * @return The console listener.
+     * @throws MavenReportException If something goes wrong.
+     */
+    protected DefaultLogger getConsoleListener()
+        throws MavenReportException
+    {
+        DefaultLogger consoleListener;
+
+        if ( useFile == null )
+        {
+            stringOutputStream = new ByteArrayOutputStream();
+            consoleListener = new DefaultLogger( stringOutputStream, false );
+        }
+        else
+        {
+            OutputStream out = getOutputStream( useFile );
+
+            consoleListener = new DefaultLogger( out, true );
+        }
+
+        return consoleListener;
+    }
+
+    private void generateReportStatics()
+        throws MavenReportException
+    {
+        ReportResource rresource = new ReportResource( PLUGIN_RESOURCES, outputDirectory );
+        try
+        {
+            rresource.copy( "images/rss.png" );
+        }
+        catch ( IOException e )
+        {
+            throw new MavenReportException( "Unable to copy static resources.", e );
+        }
+    }
+
+
+    private String getCopyright()
+    {
+        String copyright;
+        int currentYear = Calendar.getInstance().get( Calendar.YEAR );
+        if ( StringUtils.isNotEmpty( project.getInceptionYear() )
+            && !String.valueOf( currentYear ).equals( project.getInceptionYear() ) )
+        {
+            copyright = project.getInceptionYear() + " - " + currentYear;
+        }
+        else
+        {
+            copyright = String.valueOf( currentYear );
+        }
+
+        if ( ( project.getOrganization() != null ) && StringUtils.isNotEmpty( project.getOrganization().getName() ) )
+        {
+            copyright = copyright + " " + project.getOrganization().getName();
+        }
+        return copyright;
+    }
+
+    private void generateMainReport( CheckstyleResults results, ResourceBundle bundle )
+    {
+        CheckstyleReportGenerator generator =
+            new CheckstyleReportGenerator( getSink(), bundle, project.getBasedir(), siteTool );
+
+        generator.setLog( getLog() );
+        generator.setEnableRulesSummary( enableRulesSummary );
+        generator.setEnableSeveritySummary( enableSeveritySummary );
+        generator.setEnableFilesSummary( enableFilesSummary );
+        generator.setEnableRSS( enableRSS );
+        generator.setCheckstyleConfig( results.getConfiguration() );
+        if ( linkXRef )
+        {
+            String relativePath = PathTool.getRelativePath( getOutputDirectory(), xrefLocation.getAbsolutePath() );
+            if ( StringUtils.isEmpty( relativePath ) )
+            {
+                relativePath = ".";
+            }
+            relativePath = relativePath + "/" + xrefLocation.getName();
+            if ( xrefLocation.exists() )
+            {
+                // XRef was already generated by manual execution of a lifecycle
+                // binding
+                generator.setXrefLocation( relativePath );
+            }
+            else
+            {
+                // Not yet generated - check if the report is on its way
+                for ( Iterator<ReportPlugin> reports = getProject().getReportPlugins().iterator(); reports.hasNext(); )
+                {
+                    ReportPlugin report = reports.next();
+
+                    String artifactId = report.getArtifactId();
+                    if ( "maven-jxr-plugin".equals( artifactId ) || "jxr-maven-plugin".equals( artifactId ) )
+                    {
+                        generator.setXrefLocation( relativePath );
+                    }
+                }
+            }
+
+            if ( generator.getXrefLocation() == null )
+            {
+                getLog().warn( "Unable to locate Source XRef to link to - DISABLED" );
+            }
+        }
+        generator.generateReport( results );
+    }
+
+    private static ResourceBundle getBundle( Locale locale )
+    {
+        return ResourceBundle.getBundle( "checkstyle-report", locale, AbstractCheckstyleReport.class.getClassLoader() );
+    }
+
+    /** {@inheritDoc} */
+    public void setReportOutputDirectory( File reportOutputDirectory )
+    {
+        super.setReportOutputDirectory( reportOutputDirectory );
+        this.outputDirectory = reportOutputDirectory;
+    }
+}

Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/AbstractCheckstyleReport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/AbstractCheckstyleReport.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleAggregateReport.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleAggregateReport.java?rev=1178094&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleAggregateReport.java (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleAggregateReport.java Sat Oct  1 21:55:26 2011
@@ -0,0 +1,287 @@
+package org.apache.maven.plugin.checkstyle;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.reporting.MavenReportException;
+
+/**
+ * Perform a Checkstyle analysis, and generate a report on violations,
+ * aggregating the result in the project which started this mojo.
+ *
+ * @version $Id: CheckstyleReport.java 1155028 2011-08-08 17:53:46Z olamy $
+ * @goal checkstyle-aggregate
+ * @aggregator
+ * @requiresDependencyResolution compile
+ * @threadSafe
+ */
+public class CheckstyleAggregateReport
+    extends AbstractCheckstyleReport
+{
+
+    /**
+     * Specifies the names filter of the source files to be used for Checkstyle.
+     *
+     * @parameter expression="${checkstyle.includes}" default-value="**\/*.java"
+     * @required
+     */
+    private String includes;
+
+    /**
+     * Specifies the names filter of the source files to be excluded for
+     * Checkstyle.
+     *
+     * @parameter expression="${checkstyle.excludes}"
+     */
+    private String excludes;
+
+    /**
+     * <p>
+     * Specifies the location of the XML configuration to use.
+     * </p>
+     *
+     * <p>
+     * Potential values are a filesystem path, a URL, or a classpath resource.
+     * This parameter expects that the contents of the location conform to the
+     * xml format (Checkstyle <a
+     * href="http://checkstyle.sourceforge.net/config.html#Modules">Checker
+     * module</a>) configuration of rulesets.
+     * </p>
+     *
+     * <p>
+     * This parameter is resolved as resource, URL, then file. If successfully
+     * resolved, the contents of the configuration is copied into the
+     * <code>${project.build.directory}/checkstyle-configuration.xml</code>
+     * file before being passed to Checkstyle as a configuration.
+     * </p>
+     *
+     * <p>
+     * There are 4 predefined rulesets.
+     * </p>
+     *
+     * <ul>
+     * <li><code>config/sun_checks.xml</code>: Sun Checks.</li>
+     * <li><code>config/turbine_checks.xml</code>: Turbine Checks.</li>
+     * <li><code>config/avalon_checks.xml</code>: Avalon Checks.</li>
+     * <li><code>config/maven_checks.xml</code>: Maven Source Checks.</li>
+     * </ul>
+     *
+     * @parameter expression="${checkstyle.config.location}"
+     *            default-value="config/sun_checks.xml"
+     */
+    private String configLocation;
+
+    /**
+     * <p>
+     * Specifies the location of the properties file.
+     * </p>
+     *
+     * <p>
+     * This parameter is resolved as URL, File then resource. If successfully
+     * resolved, the contents of the properties location is copied into the
+     * <code>${project.build.directory}/checkstyle-checker.properties</code>
+     * file before being passed to Checkstyle for loading.
+     * </p>
+     *
+     * <p>
+     * The contents of the <code>propertiesLocation</code> will be made
+     * available to Checkstyle for specifying values for parameters within the
+     * xml configuration (specified in the <code>configLocation</code>
+     * parameter).
+     * </p>
+     *
+     * @parameter expression="${checkstyle.properties.location}"
+     * @since 2.0-beta-2
+     */
+    private String propertiesLocation;
+
+    /**
+     * Allows for specifying raw property expansion information.
+     *
+     * @parameter
+     */
+    private String propertyExpansion;
+
+    /**
+     * <p>
+     * Specifies the location of the License file (a.k.a. the header file) that
+     * can be used by Checkstyle to verify that source code has the correct
+     * license header.
+     * </p>
+     * <p>
+     * You need to use ${checkstyle.header.file} in your Checkstyle xml
+     * configuration to reference the name of this header file.
+     * </p>
+     * <p>
+     * For instance:
+     * </p>
+     * <p>
+     * <code>
+     * &lt;module name="RegexpHeader">
+     *   &lt;property name="headerFile" value="${checkstyle.header.file}"/>
+     * &lt;/module>
+     * </code>
+     * </p>
+     *
+     * @parameter expression="${checkstyle.header.file}" default-value="LICENSE.txt"
+     * @since 2.0-beta-2
+     */
+    private String headerLocation;
+
+    /**
+     * Specifies the cache file used to speed up Checkstyle on successive runs.
+     *
+     * @parameter default-value="${project.build.directory}/checkstyle-cachefile"
+     */
+    private String cacheFile;
+
+    /**
+     * <p>
+     * Specifies the location of the suppressions XML file to use.
+     * </p>
+     *
+     * <p>
+     * This parameter is resolved as resource, URL, then file. If successfully
+     * resolved, the contents of the suppressions XML is copied into the
+     * <code>${project.build.directory}/checkstyle-supressions.xml</code> file
+     * before being passed to Checkstyle for loading.
+     * </p>
+     *
+     * <p>
+     * See <code>suppressionsFileExpression</code> for the property that will
+     * be made available to your checkstyle configuration.
+     * </p>
+     *
+     * @parameter expression="${checkstyle.suppressions.location}"
+     * @since 2.0-beta-2
+     */
+    private String suppressionsLocation;
+
+    /**
+     * The key to be used in the properties for the suppressions file.
+     *
+     * @parameter expression="${checkstyle.suppression.expression}"
+     *            default-value="checkstyle.suppressions.file"
+     * @since 2.1
+     */
+    private String suppressionsFileExpression;
+
+    /**
+     * Specifies if the build should fail upon a violation.
+     *
+     * @parameter default-value="false"
+     */
+    private boolean failsOnError;
+
+    /**
+     * Specifies the location of the source directory to be used for Checkstyle.
+     *
+     * @parameter default-value="${project.build.sourceDirectory}"
+     * @required
+     */
+    private File sourceDirectory;
+
+    /**
+     * Specifies the location of the test source directory to be used for
+     * Checkstyle.
+     *
+     * @parameter default-value="${project.build.testSourceDirectory}"
+     * @since 2.2
+     */
+    private File testSourceDirectory;
+
+    /**
+     * Include or not the test source directory to be used for Checkstyle.
+     *
+     * @parameter default-value="${false}"
+     * @since 2.2
+     */
+    private boolean includeTestSourceDirectory;
+
+    /**
+     * Output errors to console.
+     *
+     * @parameter default-value="false"
+     */
+    private boolean consoleOutput;
+
+    /**
+     * The file encoding to use when reading the source files. If the property <code>project.build.sourceEncoding</code>
+     * is not set, the platform default encoding is used. <strong>Note:</strong> This parameter always overrides the
+     * property <code>charset</code> from Checkstyle's <code>TreeWalker</code> module.
+     *
+     * @parameter expression="${encoding}" default-value="${project.build.sourceEncoding}"
+     * @since 2.2
+     */
+    private String encoding;
+
+    /**
+     * The projects in the reactor for aggregation report.
+     *
+     * @parameter expression="${reactorProjects}"
+     * @readonly
+     * @since 2.8
+     */
+    private List<MavenProject> reactorProjects;
+
+    /** {@inheritDoc} */
+    protected MavenProject getProject()
+    {
+        return project;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected CheckstyleExecutorRequest createRequest()
+            throws MavenReportException
+    {
+        CheckstyleExecutorRequest request = new CheckstyleExecutorRequest();
+        request.setAggregate( true )
+            .setReactorProjects( reactorProjects )
+            .setConsoleListener( getConsoleListener() ).setConsoleOutput( consoleOutput )
+            .setExcludes( excludes ).setFailsOnError( failsOnError ).setIncludes( includes )
+            .setIncludeTestSourceDirectory( includeTestSourceDirectory ).setListener( getListener() )
+            .setLog( getLog() ).setProject( project ).setSourceDirectory( sourceDirectory )
+            .setStringOutputStream( stringOutputStream ).setSuppressionsLocation( suppressionsLocation )
+            .setTestSourceDirectory( testSourceDirectory ).setConfigLocation( configLocation )
+            .setPropertyExpansion( propertyExpansion ).setHeaderLocation( headerLocation )
+            .setCacheFile( cacheFile ).setSuppressionsFileExpression( suppressionsFileExpression )
+            .setEncoding( encoding ).setPropertiesLocation( propertiesLocation );
+        return request;
+    }
+
+
+    /** {@inheritDoc} */
+    public String getOutputName()
+    {
+        return "checkstyle-aggregate";
+    }
+
+    /** {@inheritDoc} */
+    public boolean canGenerateReport()
+    {
+        // TODO: would be good to scan the files here
+        return !skip && project.isExecutionRoot();
+    }
+}

Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleAggregateReport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleAggregateReport.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleExecutorRequest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleExecutorRequest.java?rev=1178094&r1=1178093&r2=1178094&view=diff
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleExecutorRequest.java (original)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleExecutorRequest.java Sat Oct  1 21:55:26 2011
@@ -21,6 +21,7 @@ package org.apache.maven.plugin.checksty
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.util.List;
 
 import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.project.MavenProject;
@@ -35,7 +36,7 @@ import com.puppycrawl.tools.checkstyle.a
  */
 public class CheckstyleExecutorRequest
 {
-   
+
     /**
      * Specifies the names filter of the source files to be used for Checkstyle.
      */
@@ -45,50 +46,62 @@ public class CheckstyleExecutorRequest
      * Specifies the names filter of the source files to be excluded for Checkstyle.
      */
     private String excludes;
-    
+
     private MavenProject project;
-    
+
     private Log log;
-    
+
     private String suppressionsLocation;
-    
+
     private boolean includeTestSourceDirectory;
-    
+
     private File testSourceDirectory;
-    
+
     private File sourceDirectory;
-    
+
     private boolean failsOnError;
-    
+
     private AuditListener listener;
-    
+
     private boolean consoleOutput;
-    
+
     private DefaultLogger defaultLogger;
-    
+
     private ByteArrayOutputStream stringOutputStream;
-    
+
     private String propertiesLocation;
-    
+
     //
-    
+
     private String configLocation;
 
     private String propertyExpansion;
-    
-    private String headerLocation; 
-    
-    private String cacheFile;  
-    
+
+    private String headerLocation;
+
+    private String cacheFile;
+
     private String suppressionsFileExpression;
-    
-    private String encoding; 
 
+    private String encoding;
+
+    private boolean aggregate = false;
+
+    private List<MavenProject> reactorProjects;
+
+    /**
+     * Constructor.
+     */
     public CheckstyleExecutorRequest( )
     {
-        //nothing 
-    }    
-    
+        //nothing
+    }
+
+    /**
+     * Returns the includes parameter.
+     *
+     * @return The includes parameter.
+     */
     public String getIncludes()
     {
         return includes;
@@ -209,7 +222,7 @@ public class CheckstyleExecutorRequest
         this.consoleOutput = consoleOutput;
         return this;
     }
-    
+
     public CheckstyleExecutorRequest setConsoleListener( DefaultLogger defaultLogger )
     {
         this.defaultLogger = defaultLogger;
@@ -231,7 +244,7 @@ public class CheckstyleExecutorRequest
         this.stringOutputStream = stringOutputStream;
         return this;
     }
-    
+
     public String getConfigLocation()
     {
         return configLocation;
@@ -253,7 +266,7 @@ public class CheckstyleExecutorRequest
         this.propertyExpansion = propertyExpansion;
         return this;
     }
-    
+
     public String getHeaderLocation()
     {
         return headerLocation;
@@ -296,8 +309,8 @@ public class CheckstyleExecutorRequest
     {
         this.encoding = encoding;
         return this;
-    }    
-    
+    }
+
     public String getPropertiesLocation()
     {
         return propertiesLocation;
@@ -306,5 +319,49 @@ public class CheckstyleExecutorRequest
     public void setPropertiesLocation( String propertiesLocation )
     {
         this.propertiesLocation = propertiesLocation;
-    }    
+    }
+
+    /**
+     * Returns true if the report is aggregated.
+     *
+     * @return <code>true</code> if the report is aggregated.
+     */
+    public boolean isAggregate()
+    {
+        return aggregate;
+    }
+
+    /**
+     * Sets the aggregate parameter.
+     *
+     * @param pAggregate <code>true</code> if an aggregated report is desidered.
+     * @return This object.
+     */
+    public CheckstyleExecutorRequest setAggregate( boolean pAggregate )
+    {
+        this.aggregate = pAggregate;
+        return this;
+    }
+
+    /**
+     * Returns the list of reactor projects.
+     *
+     * @return The reactor projects.
+     */
+    public List<MavenProject> getReactorProjects()
+    {
+        return reactorProjects;
+    }
+
+    /**
+     * Sets the list of reactor projects.
+     *
+     * @param pReactorProjects The reactor projects.
+     * @return This object.
+     */
+    public CheckstyleExecutorRequest setReactorProjects( List<MavenProject> pReactorProjects )
+    {
+        this.reactorProjects = pReactorProjects;
+        return this;
+    }
 }

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=1178094&r1=1178093&r2=1178094&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 Oct  1 21:55:26 2011
@@ -19,39 +19,17 @@ package org.apache.maven.plugin.checksty
  * under the License.
  */
 
-import java.io.ByteArrayOutputStream;
 import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
 import java.net.URL;
-import java.util.Calendar;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Locale;
 import java.util.Map;
-import java.util.ResourceBundle;
 
-import org.apache.maven.doxia.siterenderer.Renderer;
-import org.apache.maven.doxia.tools.SiteTool;
-import org.apache.maven.model.ReportPlugin;
-import org.apache.maven.plugin.checkstyle.rss.CheckstyleRssGenerator;
-import org.apache.maven.plugin.checkstyle.rss.CheckstyleRssGeneratorRequest;
 import org.apache.maven.project.MavenProject;
-import org.apache.maven.reporting.AbstractMavenReport;
 import org.apache.maven.reporting.MavenReportException;
-import org.codehaus.plexus.resource.ResourceManager;
-import org.codehaus.plexus.resource.loader.FileResourceLoader;
-import org.codehaus.plexus.util.PathTool;
 import org.codehaus.plexus.util.StringUtils;
 
-import com.puppycrawl.tools.checkstyle.DefaultLogger;
-import com.puppycrawl.tools.checkstyle.XMLLogger;
-import com.puppycrawl.tools.checkstyle.api.AuditListener;
-import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
-
 /**
  * Perform a Checkstyle analysis, and generate a report on violations.
  *
@@ -64,10 +42,8 @@ import com.puppycrawl.tools.checkstyle.a
  * @threadSafe
  */
 public class CheckstyleReport
-    extends AbstractMavenReport
+    extends AbstractCheckstyleReport
 {
-    public static final String PLUGIN_RESOURCES = "org/apache/maven/plugin/checkstyle";
-
     /**
      * @deprecated Remove with format parameter.
      */
@@ -86,56 +62,6 @@ public class CheckstyleReport
     }
 
     /**
-     * Skip entire check.
-     *
-     * @parameter expression="${checkstyle.skip}" default-value="false"
-     * @since 2.2
-     */
-    private boolean skip;
-
-    /**
-     * The output directory for the report. Note that this parameter is only
-     * evaluated if the goal is run directly from the command line. If the goal
-     * is run indirectly as part of a site generation, the output directory
-     * configured in Maven Site Plugin is used instead.
-     *
-     * @parameter default-value="${project.reporting.outputDirectory}"
-     * @required
-     */
-    private File outputDirectory;
-
-    /**
-     * Specifies if the Rules summary should be enabled or not.
-     *
-     * @parameter expression="${checkstyle.enable.rules.summary}"
-     *            default-value="true"
-     */
-    private boolean enableRulesSummary;
-
-    /**
-     * Specifies if the Severity summary should be enabled or not.
-     *
-     * @parameter expression="${checkstyle.enable.severity.summary}"
-     *            default-value="true"
-     */
-    private boolean enableSeveritySummary;
-
-    /**
-     * Specifies if the Files summary should be enabled or not.
-     *
-     * @parameter expression="${checkstyle.enable.files.summary}"
-     *            default-value="true"
-     */
-    private boolean enableFilesSummary;
-
-    /**
-     * Specifies if the RSS should be enabled or not.
-     *
-     * @parameter expression="${checkstyle.enable.rss}" default-value="true"
-     */
-    private boolean enableRSS;
-
-    /**
      * Specifies the names filter of the source files to be used for Checkstyle.
      *
      * @parameter expression="${checkstyle.includes}" default-value="**\/*.java"
@@ -289,24 +215,6 @@ public class CheckstyleReport
     private String cacheFile;
 
     /**
-     * If <code>null</code>, the Checkstyle plugin will display violations on stdout.
-     * Otherwise, a text file will be created with the violations.
-     *
-     * @parameter
-     */
-    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>
@@ -350,24 +258,6 @@ public class CheckstyleReport
     private String suppressionsFile;
 
     /**
-     * Specifies the path and filename to save the checkstyle output. The format
-     * of the output file is determined by the <code>outputFileFormat</code>
-     * parameter.
-     *
-     * @parameter expression="${checkstyle.output.file}"
-     *            default-value="${project.build.directory}/checkstyle-result.xml"
-     */
-    private File outputFile;
-
-    /**
-     * Specifies the format of the output to be used when writing to the output
-     * file. Valid values are "plain" and "xml".
-     *
-     * @parameter expression="${checkstyle.output.format}" default-value="xml"
-     */
-    private String outputFileFormat;
-
-    /**
      * <p>
      * Specifies the location of the package names XML to be used to configure
      * the Checkstyle <a
@@ -428,15 +318,6 @@ public class CheckstyleReport
     private boolean includeTestSourceDirectory;
 
     /**
-     * The Maven Project Object.
-     *
-     * @parameter default-value="${project}"
-     * @required
-     * @readonly
-     */
-    private MavenProject project;
-
-    /**
      * Output errors to console.
      *
      * @parameter default-value="false"
@@ -444,22 +325,6 @@ public class CheckstyleReport
     private boolean consoleOutput;
 
     /**
-     * Link the violation line numbers to the source xref. Will link
-     * automatically if Maven JXR plugin is being used.
-     *
-     * @parameter expression="${linkXRef}" default-value="true"
-     * @since 2.1
-     */
-    private boolean linkXRef;
-
-    /**
-     * Location of the Xrefs to link to.
-     *
-     * @parameter default-value="${project.reporting.outputDirectory}/xref"
-     */
-    private File xrefLocation;
-
-    /**
      * The file encoding to use when reading the source files. If the property <code>project.build.sourceEncoding</code>
      * is not set, the platform default encoding is used. <strong>Note:</strong> This parameter always overrides the
      * property <code>charset</code> from Checkstyle's <code>TreeWalker</code> module.
@@ -469,59 +334,6 @@ public class CheckstyleReport
      */
     private String encoding;
 
-    /**
-     * @component
-     * @required
-     * @readonly
-     */
-    private Renderer siteRenderer;
-
-    private ByteArrayOutputStream stringOutputStream;
-
-    /**
-     * @component
-     * @required
-     * @readonly
-     */
-    private ResourceManager locator;
-
-    /**
-     * CheckstyleRssGenerator.
-     *
-     * @since 2.4
-     * @component role="org.apache.maven.plugin.checkstyle.rss.CheckstyleRssGenerator" role-hint="default"
-     * @required
-     * @readonly
-     */
-    protected CheckstyleRssGenerator checkstyleRssGenerator;
-
-    /**
-     * @since 2.5
-     * @component role="org.apache.maven.plugin.checkstyle.CheckstyleExecutor" role-hint="default"
-     * @required
-     * @readonly
-     */
-    protected CheckstyleExecutor checkstyleExecutor;
-    
-
-    /** {@inheritDoc} */
-    public String getName( Locale locale )
-    {
-        return getBundle( locale ).getString( "report.checkstyle.name" );
-    }
-
-    /** {@inheritDoc} */
-    public String getDescription( Locale locale )
-    {
-        return getBundle( locale ).getString( "report.checkstyle.description" );
-    }
-
-    /** {@inheritDoc} */
-    protected String getOutputDirectory()
-    {
-        return outputDirectory.getAbsolutePath();
-    }
-
     /** {@inheritDoc} */
     protected MavenProject getProject()
     {
@@ -529,163 +341,43 @@ public class CheckstyleReport
     }
 
     /** {@inheritDoc} */
-    protected Renderer getSiteRenderer()
-    {
-        return siteRenderer;
-    }
-
-    /** {@inheritDoc} */
     public void executeReport( Locale locale )
         throws MavenReportException
     {
-        if ( !skip )
-        {
-            mergeDeprecatedInfo();
-
-            locator.addSearchPath( FileResourceLoader.ID, project.getFile().getParentFile().getAbsolutePath() );
-            locator.addSearchPath( "url", "" );
-
-            locator.setOutputDirectory( new File( project.getBuild().getDirectory() ) );
-
-            if ( !canGenerateReport() )
-            {
-                getLog().info( "Source directory does not exist - skipping report." );
-                return;
-            }
-
-            // for when we start using maven-shared-io and
-            // maven-shared-monitor...
-            // locator = new Locator( new MojoLogMonitorAdaptor( getLog() ) );
-
-            // locator = new Locator( getLog(), new File(
-            // project.getBuild().getDirectory() ) );
-
-            ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
-
-            try
-            {
-                CheckstyleExecutorRequest request = new CheckstyleExecutorRequest();
-                request.setConsoleListener( getConsoleListener() ).setConsoleOutput( consoleOutput )
-                    .setExcludes( excludes ).setFailsOnError( failsOnError ).setIncludes( includes )
-                    .setIncludeTestSourceDirectory( includeTestSourceDirectory ).setListener( getListener() )
-                    .setLog( getLog() ).setProject( project ).setSourceDirectory( sourceDirectory )
-                    .setStringOutputStream( stringOutputStream ).setSuppressionsLocation( suppressionsLocation )
-                    .setTestSourceDirectory( testSourceDirectory ).setConfigLocation( configLocation )
-                    .setPropertyExpansion( propertyExpansion ).setHeaderLocation( headerLocation )
-                    .setCacheFile( cacheFile ).setSuppressionsFileExpression( suppressionsFileExpression )
-                    .setEncoding( encoding ).setPropertiesLocation( propertiesLocation );
-
-                CheckstyleResults results = checkstyleExecutor.executeCheckstyle( request );
-
-                ResourceBundle bundle = getBundle( locale );
-                generateReportStatics();
-                generateMainReport( results, bundle );
-                if ( enableRSS )
-                {
-                    CheckstyleRssGeneratorRequest checkstyleRssGeneratorRequest =
-                        new CheckstyleRssGeneratorRequest( this.project, this.getCopyright(), outputDirectory, getLog() );
-                    checkstyleRssGenerator.generateRSS( results, checkstyleRssGeneratorRequest );
-                }
-
-            }
-            catch ( CheckstyleException e )
-            {
-                throw new MavenReportException( "Failed during checkstyle configuration", e );
-            }
-            catch ( CheckstyleExecutorException e )
-            {
-                throw new MavenReportException( "Failed during checkstyle execution", e );
-            }
-            finally
-            {
-                //be sure to restore original context classloader
-                Thread.currentThread().setContextClassLoader( currentClassLoader );
-            }
-        }
+        mergeDeprecatedInfo();
+        super.executeReport( locale );
     }
 
-    private void generateReportStatics()
-        throws MavenReportException
-    {
-        ReportResource rresource = new ReportResource( PLUGIN_RESOURCES, outputDirectory );
-        try
-        {
-            rresource.copy( "images/rss.png" );
-        }
-        catch ( IOException e )
-        {
-            throw new MavenReportException( "Unable to copy static resources.", e );
-        }
+    /**
+     * {@inheritDoc}
+     */
+    protected CheckstyleExecutorRequest createRequest()
+            throws MavenReportException
+    {
+        CheckstyleExecutorRequest request = new CheckstyleExecutorRequest();
+        request.setConsoleListener( getConsoleListener() ).setConsoleOutput( consoleOutput )
+            .setExcludes( excludes ).setFailsOnError( failsOnError ).setIncludes( includes )
+            .setIncludeTestSourceDirectory( includeTestSourceDirectory ).setListener( getListener() )
+            .setLog( getLog() ).setProject( project ).setSourceDirectory( sourceDirectory )
+            .setStringOutputStream( stringOutputStream ).setSuppressionsLocation( suppressionsLocation )
+            .setTestSourceDirectory( testSourceDirectory ).setConfigLocation( configLocation )
+            .setPropertyExpansion( propertyExpansion ).setHeaderLocation( headerLocation )
+            .setCacheFile( cacheFile ).setSuppressionsFileExpression( suppressionsFileExpression )
+            .setEncoding( encoding ).setPropertiesLocation( propertiesLocation );
+        return request;
     }
 
-
-    private String getCopyright()
+    /** {@inheritDoc} */
+    public String getOutputName()
     {
-        String copyright;
-        int currentYear = Calendar.getInstance().get( Calendar.YEAR );
-        if ( StringUtils.isNotEmpty( project.getInceptionYear() )
-            && !String.valueOf( currentYear ).equals( project.getInceptionYear() ) )
-        {
-            copyright = project.getInceptionYear() + " - " + currentYear;
-        }
-        else
-        {
-            copyright = String.valueOf( currentYear );
-        }
-
-        if ( ( project.getOrganization() != null ) && StringUtils.isNotEmpty( project.getOrganization().getName() ) )
-        {
-            copyright = copyright + " " + project.getOrganization().getName();
-        }
-        return copyright;
+        return "checkstyle";
     }
 
-    private void generateMainReport( CheckstyleResults results, ResourceBundle bundle )
+    /** {@inheritDoc} */
+    public boolean canGenerateReport()
     {
-        CheckstyleReportGenerator generator =
-            new CheckstyleReportGenerator( getSink(), bundle, project.getBasedir(), siteTool );
-
-        generator.setLog( getLog() );
-        generator.setEnableRulesSummary( enableRulesSummary );
-        generator.setEnableSeveritySummary( enableSeveritySummary );
-        generator.setEnableFilesSummary( enableFilesSummary );
-        generator.setEnableRSS( enableRSS );
-        generator.setCheckstyleConfig( results.getConfiguration() );
-        if ( linkXRef )
-        {
-            String relativePath = PathTool.getRelativePath( getOutputDirectory(), xrefLocation.getAbsolutePath() );
-            if ( StringUtils.isEmpty( relativePath ) )
-            {
-                relativePath = ".";
-            }
-            relativePath = relativePath + "/" + xrefLocation.getName();
-            if ( xrefLocation.exists() )
-            {
-                // XRef was already generated by manual execution of a lifecycle
-                // binding
-                generator.setXrefLocation( relativePath );
-            }
-            else
-            {
-                // Not yet generated - check if the report is on its way
-                for ( Iterator<ReportPlugin> reports = getProject().getReportPlugins().iterator(); reports.hasNext(); )
-                {
-                    ReportPlugin report = reports.next();
-
-                    String artifactId = report.getArtifactId();
-                    if ( "maven-jxr-plugin".equals( artifactId ) || "jxr-maven-plugin".equals( artifactId ) )
-                    {
-                        generator.setXrefLocation( relativePath );
-                    }
-                }
-            }
-
-            if ( generator.getXrefLocation() == null )
-            {
-                getLog().warn( "Unable to locate Source XRef to link to - DISABLED" );
-            }
-        }
-        generator.generateReport( results );
+        // TODO: would be good to scan the files here
+        return !skip && ( sourceDirectory.exists() || ( includeTestSourceDirectory && testSourceDirectory.exists() ) );
     }
 
     /**
@@ -733,101 +425,4 @@ public class CheckstyleReport
         }
     }
 
-
-    /** {@inheritDoc} */
-    public String getOutputName()
-    {
-        return "checkstyle";
-    }
-
-    private AuditListener getListener()
-        throws MavenReportException
-    {
-        AuditListener listener = null;
-
-        if ( StringUtils.isNotEmpty( outputFileFormat ) )
-        {
-            File resultFile = outputFile;
-
-            OutputStream out = getOutputStream( resultFile );
-
-            if ( "xml".equals( outputFileFormat ) )
-            {
-                listener = new XMLLogger( out, true );
-            }
-            else if ( "plain".equals( outputFileFormat ) )
-            {
-                listener = new DefaultLogger( out, true );
-            }
-            else
-            {
-                // TODO: failure if not a report
-                throw new MavenReportException( "Invalid output file format: (" + outputFileFormat
-                    + "). Must be 'plain' or 'xml'." );
-            }
-        }
-
-        return listener;
-    }
-
-    private OutputStream getOutputStream( File file )
-        throws MavenReportException
-    {
-        File parentFile = file.getAbsoluteFile().getParentFile();
-
-        if ( !parentFile.exists() )
-        {
-            parentFile.mkdirs();
-        }
-
-        FileOutputStream fileOutputStream;
-        try
-        {
-            fileOutputStream = new FileOutputStream( file );
-        }
-        catch ( FileNotFoundException e )
-        {
-            throw new MavenReportException( "Unable to create output stream: " + file, e );
-        }
-        return fileOutputStream;
-    }
-
-    private DefaultLogger getConsoleListener()
-        throws MavenReportException
-    {
-        DefaultLogger consoleListener;
-
-        if ( useFile == null )
-        {
-            stringOutputStream = new ByteArrayOutputStream();
-            consoleListener = new DefaultLogger( stringOutputStream, false );
-        }
-        else
-        {
-            OutputStream out = getOutputStream( useFile );
-
-            consoleListener = new DefaultLogger( out, true );
-        }
-
-        return consoleListener;
-    }
-
-    private static ResourceBundle getBundle( Locale locale )
-    {
-        return ResourceBundle.getBundle( "checkstyle-report", locale, CheckstyleReport.class.getClassLoader() );
-    }
-
-    /** {@inheritDoc} */
-    public boolean canGenerateReport()
-    {
-        // TODO: would be good to scan the files here
-        return sourceDirectory.exists() || ( includeTestSourceDirectory && testSourceDirectory.exists() );
-    }
-    
-    /** {@inheritDoc} */
-    public void setReportOutputDirectory( File reportOutputDirectory )
-    {
-        super.setReportOutputDirectory( reportOutputDirectory );
-        this.outputDirectory = reportOutputDirectory;
-    }
 }

Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReportListener.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReportListener.java?rev=1178094&r1=1178093&r2=1178094&view=diff
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReportListener.java (original)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReportListener.java Sat Oct  1 21:55:26 2011
@@ -74,6 +74,16 @@ public class CheckstyleReportListener
     }
 
     /**
+     * @param configuration checkstyle configuration
+     * @since 2.5
+     */
+    public CheckstyleReportListener( Configuration configuration )
+    {
+        this.sourceDirectories = new ArrayList<File>();
+        this.checkstyleConfiguration = configuration;
+    }
+
+    /**
      * @param sourceDirectory assume that is <code>sourceDirectory</code> is a not null directory and exists
      */
     public void addSourceDirectory( File sourceDirectory )

Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/DefaultCheckstyleExecutor.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/DefaultCheckstyleExecutor.java?rev=1178094&r1=1178093&r2=1178094&view=diff
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/DefaultCheckstyleExecutor.java (original)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/DefaultCheckstyleExecutor.java Sat Oct  1 21:55:26 2011
@@ -28,7 +28,6 @@ import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.List;
 import java.util.Properties;
 
@@ -56,7 +55,8 @@ import com.puppycrawl.tools.checkstyle.f
 
 /**
  * @author <a href="mailto:olamy@apache.org">olamy</a>
- * @plexus.component role="org.apache.maven.plugin.checkstyle.CheckstyleExecutor" role-hint="default" instantiation-strategy="per-lookup"
+ * @plexus.component role="org.apache.maven.plugin.checkstyle.CheckstyleExecutor" role-hint="default"
+ *                   instantiation-strategy="per-lookup"
  * @since 2.5
  * @version $Id$
  */
@@ -86,7 +86,8 @@ public class DefaultCheckstyleExecutor
         {
             getLogger().debug( "executeCheckstyle start headerLocation : " + request.getHeaderLocation() );
         }
-        locator.setOutputDirectory( new File( request.getProject().getBuild().getDirectory() ) );
+        MavenProject project = request.getProject();
+        locator.setOutputDirectory( new File( project.getBuild().getDirectory() ) );
         File[] files;
         try
         {
@@ -105,27 +106,19 @@ public class DefaultCheckstyleExecutor
         // for ..." errors
         List<String> classPathStrings = new ArrayList<String>();
         List<String> outputDirectories = new ArrayList<String>();
-        try
-        {
-            classPathStrings = request.getProject().getCompileClasspathElements();
-            outputDirectories.add( request.getProject().getBuild().getOutputDirectory() );
-
-            if ( request.isIncludeTestSourceDirectory() && ( request.getSourceDirectory() != null )
-                && ( request.getTestSourceDirectory().exists() ) && ( request.getTestSourceDirectory().isDirectory() ) )
-            {
-                classPathStrings = request.getProject().getTestClasspathElements();
-                outputDirectories.add( request.getProject().getBuild().getTestOutputDirectory() );
+        File sourceDirectory = request.getSourceDirectory();
+        File testSourceDirectory = request.getTestSourceDirectory();
+        prepareCheckstylePaths( request, project, classPathStrings, outputDirectories, sourceDirectory,
+                                testSourceDirectory );
+        if ( request.isAggregate() )
+        {
+            for ( MavenProject childProject : request.getReactorProjects() )
+            {
+                prepareCheckstylePaths( request, childProject, classPathStrings, outputDirectories,
+                                        new File( childProject.getBuild().getSourceDirectory() ),
+                                        new File( childProject.getBuild().getTestSourceDirectory() ) );
             }
         }
-        catch ( DependencyResolutionRequiredException e )
-        {
-            throw new CheckstyleExecutorException( e.getMessage(), e );
-        }
-
-        if ( classPathStrings == null )
-        {
-            classPathStrings = Collections.EMPTY_LIST;
-        }
 
         List<URL> urls = new ArrayList<URL>( classPathStrings.size() );
 
@@ -188,11 +181,15 @@ public class DefaultCheckstyleExecutor
             checker.addListener( request.getConsoleListener() );
         }
 
-        CheckstyleReportListener sinkListener = new CheckstyleReportListener( request.getSourceDirectory(), configuration );
-        if ( request.isIncludeTestSourceDirectory() && ( request.getTestSourceDirectory() != null )
-            && ( request.getTestSourceDirectory().exists() ) && ( request.getTestSourceDirectory().isDirectory() ) )
+        CheckstyleReportListener sinkListener = new CheckstyleReportListener( configuration );
+        addSourceDirectory( sinkListener, sourceDirectory, testSourceDirectory, request );
+        if ( request.isAggregate() )
         {
-            sinkListener.addSourceDirectory( request.getTestSourceDirectory() );
+            for ( MavenProject childProject : request.getReactorProjects() )
+            {
+                addSourceDirectory( sinkListener, new File( childProject.getBuild().getSourceDirectory() ),
+                                    new File( childProject.getBuild().getSourceDirectory() ), request );
+            }
         }
 
         checker.addListener( sinkListener );
@@ -222,6 +219,20 @@ public class DefaultCheckstyleExecutor
         return sinkListener.getResults();
     }
 
+    protected void addSourceDirectory( CheckstyleReportListener sinkListener, File sourceDirectory,
+                                       File testSourceDirectory, CheckstyleExecutorRequest request )
+    {
+        if (sourceDirectory != null)
+        {
+            sinkListener.addSourceDirectory( sourceDirectory );
+        }
+        if ( request.isIncludeTestSourceDirectory() && ( testSourceDirectory != null )
+            && ( testSourceDirectory.exists() ) && ( testSourceDirectory.isDirectory() ) )
+        {
+            sinkListener.addSourceDirectory( testSourceDirectory );
+        }
+    }
+
     public Configuration getConfiguration( CheckstyleExecutorRequest request )
         throws CheckstyleExecutorException
     {
@@ -266,16 +277,17 @@ public class DefaultCheckstyleExecutor
                     if ( module instanceof DefaultConfiguration )
                     {
                         //MCHECKSTYLE-132 DefaultConfiguration addAttribute has changed in checkstyle 5.3
-                        try 
+                        try
                         {
                             if ( ( (DefaultConfiguration) module ).getAttribute( "cacheFile" ) == null )
                             {
                                 ( (DefaultConfiguration) module ).addAttribute( "cacheFile", request.getCacheFile() );
                             }
                         }
-                        catch ( CheckstyleException ex ) 
+                        catch ( CheckstyleException ex )
                         {
-                            //MCHECKSTYLE-159 - checkstyle 5.4 throws an exception instead of return null if "cacheFile" doesn't exist
+                            //MCHECKSTYLE-159 - checkstyle 5.4 throws an exception instead of return null if "cacheFile"
+                            // doesn't exist
                             ( (DefaultConfiguration) module ).addAttribute( "cacheFile", request.getCacheFile() );
                         }
                     }
@@ -293,6 +305,32 @@ public class DefaultCheckstyleExecutor
         }
     }
 
+    private void prepareCheckstylePaths( CheckstyleExecutorRequest request, MavenProject project,
+                                         List<String> classPathStrings, List<String> outputDirectories,
+                                         File sourceDirectory, File testSourceDirectory )
+        throws CheckstyleExecutorException
+    {
+        try
+        {
+            outputDirectories.add( project.getBuild().getOutputDirectory() );
+
+            if ( request.isIncludeTestSourceDirectory() && ( sourceDirectory != null )
+                && ( testSourceDirectory.exists() ) && ( testSourceDirectory.isDirectory() ) )
+            {
+                classPathStrings.addAll( project.getTestClasspathElements() );
+                outputDirectories.add( project.getBuild().getTestOutputDirectory() );
+            }
+            else
+            {
+                classPathStrings.addAll( project.getCompileClasspathElements() );
+            }
+        }
+        catch ( DependencyResolutionRequiredException e )
+        {
+            throw new CheckstyleExecutorException( e.getMessage(), e );
+        }
+    }
+
     private Properties getOverridingProperties( CheckstyleExecutorRequest request )
         throws CheckstyleExecutorException
     {
@@ -317,7 +355,9 @@ public class DefaultCheckstyleExecutor
                     {
                         p.load( properties );
                     }
-                } finally {
+                }
+                finally
+                {
                     IOUtils.closeQuietly( properties );
                 }
             }
@@ -419,23 +459,40 @@ public class DefaultCheckstyleExecutor
             excludesStr.append( defaultExcludes[i] );
         }
 
-        if ( request.getSourceDirectory() == null || !request.getSourceDirectory().exists() )
-     {
-            return EMPTY_FILE_ARRAY;
-        }
+        File sourceDirectory = request.getSourceDirectory();
 
-        List<File> files =
-            FileUtils.getFiles( request.getSourceDirectory(), request.getIncludes(), excludesStr.toString() );
-        if ( request.isIncludeTestSourceDirectory() && ( request.getTestSourceDirectory() != null )
-            && ( request.getTestSourceDirectory().exists() ) && ( request.getTestSourceDirectory().isDirectory() ) )
+        List<File> files = new ArrayList<File>();
+        addFilesToProcess( request, excludesStr, sourceDirectory, files );
+        if ( request.isAggregate() )
         {
-            files.addAll( FileUtils.getFiles( request.getTestSourceDirectory(), request.getIncludes(),
-                                              excludesStr.toString() ) );
+            for ( MavenProject project : request.getReactorProjects() )
+            {
+                addFilesToProcess( request, excludesStr, new File( project.getBuild().getSourceDirectory() ), files );
+            }
         }
 
         return (File[]) files.toArray( EMPTY_FILE_ARRAY );
     }
 
+    private void addFilesToProcess( CheckstyleExecutorRequest request, StringBuffer excludesStr, File sourceDirectory,
+                                    List<File> files )
+        throws IOException
+    {
+        if ( sourceDirectory == null || !sourceDirectory.exists() )
+        {
+            return;
+        }
+        files.addAll(
+            FileUtils.getFiles( sourceDirectory, request.getIncludes(), excludesStr.toString() ) );
+        File testSourceDirectory = request.getTestSourceDirectory();
+        if ( request.isIncludeTestSourceDirectory() && ( testSourceDirectory != null )
+            && ( testSourceDirectory.exists() ) && ( testSourceDirectory.isDirectory() ) )
+        {
+            files.addAll( FileUtils.getFiles( testSourceDirectory, request.getIncludes(),
+                                              excludesStr.toString() ) );
+        }
+    }
+
     private FilterSet getSuppressions( CheckstyleExecutorRequest request )
         throws CheckstyleExecutorException
     {
@@ -472,7 +529,7 @@ public class DefaultCheckstyleExecutor
             {
                 getLogger().debug( "request.getConfigLocation() " + request.getConfigLocation() );
             }
-            
+
             MavenProject parent = request.getProject();
             while ( parent != null && parent.getFile() != null )
             {

Modified: maven/plugins/trunk/maven-checkstyle-plugin/src/main/resources/config/maven_checks.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/main/resources/config/maven_checks.xml?rev=1178094&r1=1178093&r2=1178094&view=diff
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/main/resources/config/maven_checks.xml (original)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/main/resources/config/maven_checks.xml Sat Oct  1 21:55:26 2011
@@ -42,23 +42,23 @@ under the License.
     <!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
     <!-- module name="Translation"/ -->
 
-    <module name="FileLength"/>    
+    <module name="FileLength"/>
 
     <!-- Checks for Headers                              -->
     <!-- See http://checkstyle.sf.net/config_header.html -->
     <module name="RegexpHeader">
       <property name="headerFile" value="${checkstyle.header.file}"/>
-    </module>    
+    </module>
 
     <module name="FileTabCharacter">
         <property name="eachLine" value="true"/>
-    </module>    
+    </module>
 
     <!-- Line with trailing spaces (disabled as it's too noisy) -->
     <!--<module name="RegexpSingleline">
         <property name="format" value="\s+$"/>
         <property name="message" value="Line has trailing spaces."/>
-    </module>-->    
+    </module>-->
 
     <module name="TreeWalker">
 
@@ -89,6 +89,7 @@ under the License.
         </module>
         <module name="JavadocType">
           <property name="scope" value="protected"/>
+          <property name="allowUnknownTags" value="true" />
         </module>
         <module name="JavadocVariable">
           <property name="severity" value="info"/>

Added: maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/CheckstyleAggregateReportTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/CheckstyleAggregateReportTest.java?rev=1178094&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/CheckstyleAggregateReportTest.java (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/CheckstyleAggregateReportTest.java Sat Oct  1 21:55:26 2011
@@ -0,0 +1,190 @@
+package org.apache.maven.plugin.checkstyle;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.apache.maven.doxia.site.decoration.DecorationModel;
+import org.apache.maven.doxia.siterenderer.RendererException;
+import org.apache.maven.doxia.siterenderer.SiteRenderingContext;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.reporting.MavenReport;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.WriterFactory;
+
+/**
+ * @author Edwin Punzalan
+ * @version $Id: CheckstyleReportTest.java 952476 2010-06-07 23:00:42Z olamy $
+ */
+public class CheckstyleAggregateReportTest
+    extends AbstractMojoTestCase
+{
+    private Locale oldLocale;
+
+    /** {@inheritDoc} */
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        oldLocale = Locale.getDefault();
+        Locale.setDefault( Locale.ENGLISH );
+    }
+
+    /** {@inheritDoc} */
+    protected void tearDown()
+        throws Exception
+    {
+        super.tearDown();
+
+        Locale.setDefault( oldLocale );
+        oldLocale = null;
+    }
+    public void testMinConfiguration()
+        throws Exception
+    {
+        generateReport( "multi-plugin-config.xml" );
+    }
+
+    private File generateReport( String pluginXml )
+        throws Exception
+    {
+        File pluginXmlFile = new File( getBasedir(), "src/test/plugin-configs/" + pluginXml );
+        ResourceBundle bundle =
+            ResourceBundle.getBundle( "checkstyle-report", Locale.getDefault(), this.getClassLoader() );
+
+        CheckstyleAggregateReport mojo = (CheckstyleAggregateReport) lookupMojo( "checkstyle-aggregate", pluginXmlFile );
+
+        assertNotNull( "Mojo found.", mojo );
+
+        mojo.execute();
+
+        File outputFile = (File) getVariableValueFromObject( mojo, "outputFile" );
+        assertNotNull( "Test output file", outputFile );
+        assertTrue( "Test output file exists", outputFile.exists() );
+
+        String cacheFile = (String) getVariableValueFromObject( mojo, "cacheFile" );
+        if ( cacheFile != null )
+        {
+            assertTrue( "Test cache file exists", new File( cacheFile ).exists() );
+        }
+
+        MavenReport reportMojo = (MavenReport) mojo;
+        File outputDir = reportMojo.getReportOutputDirectory();
+
+        Boolean rss = (Boolean) getVariableValueFromObject( mojo, "enableRSS" );
+        if ( rss.booleanValue() )
+        {
+            File rssFile = new File( outputDir, "checkstyle.rss" );
+            assertTrue( "Test rss file exists", rssFile.exists() );
+        }
+
+        File useFile = (File) getVariableValueFromObject( mojo, "useFile" );
+        if ( useFile != null )
+        {
+            assertTrue( "Test useFile exists", useFile.exists() );
+        }
+
+        String filename = reportMojo.getOutputName() + ".html";
+        File outputHtml = new File( outputDir, filename );
+
+        renderer( mojo, outputHtml );
+
+        assertTrue( outputHtml.getAbsolutePath() + " not generated!", outputHtml.exists() );
+
+        assertTrue( outputHtml.getAbsolutePath() + " is empty!", outputHtml.length() > 0 );
+
+        String htmlString = FileUtils.fileRead( outputHtml );
+
+        boolean searchHeaderFound =
+            ( htmlString.indexOf( "<h2>" + bundle.getString( "report.checkstyle.rules" ) ) > 0 );
+        Boolean rules = (Boolean) getVariableValueFromObject( mojo, "enableRulesSummary" );
+        if ( rules.booleanValue() )
+        {
+            assertTrue( "Test for Rules Summary", searchHeaderFound );
+        }
+        else
+        {
+            assertFalse( "Test for Rules Summary", searchHeaderFound );
+        }
+
+        searchHeaderFound =
+            ( htmlString.indexOf( "<h2>" + bundle.getString( "report.checkstyle.summary" )  ) > 0 );
+        Boolean severity = (Boolean) getVariableValueFromObject( mojo, "enableSeveritySummary" );
+        if ( severity.booleanValue() )
+        {
+            assertTrue( "Test for Severity Summary", searchHeaderFound );
+        }
+        else
+        {
+            assertFalse( "Test for Severity Summary", searchHeaderFound );
+        }
+
+        searchHeaderFound =
+            ( htmlString.indexOf( "<h2>" + bundle.getString( "report.checkstyle.files" ) ) > 0 );
+        Boolean files = (Boolean) getVariableValueFromObject( mojo, "enableFilesSummary" );
+        if ( files.booleanValue() )
+        {
+            assertTrue( "Test for Files Summary", searchHeaderFound );
+        }
+        else
+        {
+            assertFalse( "Test for Files Summary", searchHeaderFound );
+        }
+
+        return outputHtml;
+    }
+
+    /**
+     * Renderer the sink from the report mojo.
+     *
+     * @param mojo not null
+     * @param outputHtml not null
+     * @throws RendererException if any
+     * @throws IOException if any
+     */
+    private void renderer( CheckstyleAggregateReport mojo, File outputHtml )
+        throws RendererException, Exception
+    {
+        Writer writer = null;
+        SiteRenderingContext context = new SiteRenderingContext();
+        context.setDecoration( new DecorationModel() );
+        context.setTemplateName( "org/apache/maven/doxia/siterenderer/resources/default-site.vm" );
+        context.setLocale( Locale.ENGLISH );
+
+        try
+        {
+            outputHtml.getParentFile().mkdirs();
+            writer = WriterFactory.newXmlWriter( outputHtml );
+
+            mojo.execute();
+
+        }
+        finally
+        {
+            IOUtil.close( writer );
+        }
+    }
+}

Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/CheckstyleAggregateReportTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/CheckstyleAggregateReportTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/stubs/ModuleMavenProjectStub.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/stubs/ModuleMavenProjectStub.java?rev=1178094&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/stubs/ModuleMavenProjectStub.java (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/stubs/ModuleMavenProjectStub.java Sat Oct  1 21:55:26 2011
@@ -0,0 +1,108 @@
+package org.apache.maven.plugin.checkstyle.stubs;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.model.Build;
+import org.apache.maven.model.Organization;
+import org.apache.maven.model.ReportPlugin;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.codehaus.plexus.PlexusTestCase;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Collections;
+import java.io.File;
+
+/**
+ * @author Edwin Punzalan
+ * @version $Id: MinMavenProjectStub.java 942969 2010-05-11 00:32:30Z hboutemy $
+ */
+public class ModuleMavenProjectStub
+    extends org.apache.maven.plugin.testing.stubs.MavenProjectStub
+{
+
+    /** {@inheritDoc} */
+    public List<String> getCompileClasspathElements()
+        throws DependencyResolutionRequiredException
+    {
+        return Collections.singletonList( PlexusTestCase.getBasedir() + "/target/classes" );
+    }
+
+    /** {@inheritDoc} */
+    public List<String> getTestClasspathElements()
+        throws DependencyResolutionRequiredException
+    {
+        List<String> list = new ArrayList<String>( getCompileClasspathElements() );
+        list.add( PlexusTestCase.getBasedir() + "/target/test-classes" );
+        return list;
+    }
+
+    /** {@inheritDoc} */
+    public File getBasedir()
+    {
+        return new File( PlexusTestCase.getBasedir() );
+    }
+
+    /** {@inheritDoc} */
+    public List<ReportPlugin> getReportPlugins()
+    {
+        ReportPlugin jxrPlugin = new ReportPlugin();
+
+        jxrPlugin.setArtifactId( "maven-jxr-plugin" );
+
+        return Collections.singletonList( jxrPlugin );
+    }
+
+    /** {@inheritDoc} */
+    public Organization getOrganization()
+    {
+        Organization organization = new Organization();
+
+        organization.setName( "maven-plugin-tests" );
+
+        return organization;
+    }
+
+    /** {@inheritDoc} */
+    public String getInceptionYear()
+    {
+        return "2006";
+    }
+
+    /** {@inheritDoc} */
+    public Build getBuild()
+    {
+        Build build = new Build();
+
+        build.setDirectory( PlexusTestCase.getBasedir() + "/target/test-harness/checkstyle/multi" );
+        build.setSourceDirectory( PlexusTestCase.getBasedir() + "/src/test/test-sources" );
+        build.setTestSourceDirectory( PlexusTestCase.getBasedir() + "/src/test/java" );
+
+        return build;
+    }
+
+    /** {@inheritDoc} */
+    public File getFile()
+    {
+        File file = new File( getBasedir(), "pom.xml" );
+
+        return file;
+    }
+}

Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/stubs/ModuleMavenProjectStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/stubs/ModuleMavenProjectStub.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/stubs/MultiMavenProjectStub.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/stubs/MultiMavenProjectStub.java?rev=1178094&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/stubs/MultiMavenProjectStub.java (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/stubs/MultiMavenProjectStub.java Sat Oct  1 21:55:26 2011
@@ -0,0 +1,115 @@
+package org.apache.maven.plugin.checkstyle.stubs;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.model.Build;
+import org.apache.maven.model.Organization;
+import org.apache.maven.model.ReportPlugin;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.PlexusTestCase;
+
+/**
+ * @version $Id: MinMavenProjectStub.java 942969 2010-05-11 00:32:30Z hboutemy $
+ */
+public class MultiMavenProjectStub
+    extends org.apache.maven.plugin.testing.stubs.MavenProjectStub
+{
+
+    public MultiMavenProjectStub()
+    {
+        setExecutionRoot( true );
+    }
+
+    @Override
+    public MavenProject getExecutionProject()
+    {
+        return this;
+    }
+
+    /** {@inheritDoc} */
+    public List<String> getCompileClasspathElements()
+        throws DependencyResolutionRequiredException
+    {
+        return Collections.EMPTY_LIST;
+    }
+
+    /** {@inheritDoc} */
+    public List<String> getTestClasspathElements()
+        throws DependencyResolutionRequiredException
+    {
+        return Collections.EMPTY_LIST;
+    }
+
+    /** {@inheritDoc} */
+    public File getBasedir()
+    {
+        return new File( PlexusTestCase.getBasedir() );
+    }
+
+    /** {@inheritDoc} */
+    public List<ReportPlugin> getReportPlugins()
+    {
+        ReportPlugin jxrPlugin = new ReportPlugin();
+
+        jxrPlugin.setArtifactId( "maven-jxr-plugin" );
+
+        return Collections.singletonList( jxrPlugin );
+    }
+
+    /** {@inheritDoc} */
+    public Organization getOrganization()
+    {
+        Organization organization = new Organization();
+
+        organization.setName( "maven-plugin-tests" );
+
+        return organization;
+    }
+
+    /** {@inheritDoc} */
+    public String getInceptionYear()
+    {
+        return "2006";
+    }
+
+    /** {@inheritDoc} */
+    public Build getBuild()
+    {
+        Build build = new Build();
+
+        build.setDirectory( PlexusTestCase.getBasedir() + "/target/test-harness/checkstyle/multi" );
+
+        return build;
+    }
+
+    /** {@inheritDoc} */
+    public File getFile()
+    {
+        File file = new File( getBasedir(), "pom.xml" );
+
+        return file;
+    }
+}

Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/stubs/MultiMavenProjectStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/stubs/MultiMavenProjectStub.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/multi-plugin-config.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/multi-plugin-config.xml?rev=1178094&view=auto
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/multi-plugin-config.xml (added)
+++ maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/multi-plugin-config.xml Sat Oct  1 21:55:26 2011
@@ -0,0 +1,50 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <configuration>
+          <outputDirectory>${basedir}/target/test-harness/checkstyle/multi</outputDirectory>
+          <enableRulesSummary>true</enableRulesSummary>
+          <enableSeveritySummary>true</enableSeveritySummary>
+          <enableFilesSummary>true</enableFilesSummary>
+          <enableRSS>true</enableRSS>
+          <includes>**/*.java</includes>
+          <configLocation>config/sun_checks.xml</configLocation>
+          <headerLocation>${basedir}/src/test/test-sources/LICENSE.txt</headerLocation>
+          <cacheFile>${basedir}/target/test-harness/checkstyle/multi/checkstyle-cachefile</cacheFile>
+          <outputFile>${basedir}/target/test-harness/checkstyle/multi/checkstyle-result.xml</outputFile>
+          <outputFileFormat>xml</outputFileFormat>
+          <failsOnError>false</failsOnError>
+          <project implementation="org.apache.maven.plugin.checkstyle.stubs.MultiMavenProjectStub"/>
+          <reactorProjects>
+            <project implementation="org.apache.maven.plugin.checkstyle.stubs.ModuleMavenProjectStub" />
+          </reactorProjects>
+          <consoleOutput>false</consoleOutput>
+          <linkXRef>true</linkXRef>
+          <xrefLocation>${basedir}/target/site/xref</xrefLocation>
+          <encoding>UTF-8</encoding>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/multi-plugin-config.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-checkstyle-plugin/src/test/plugin-configs/multi-plugin-config.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision