View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.plugins.checkstyle;
20  
21  import org.apache.maven.plugins.annotations.Mojo;
22  import org.apache.maven.plugins.annotations.ResolutionScope;
23  import org.apache.maven.plugins.checkstyle.exec.CheckstyleExecutorRequest;
24  import org.apache.maven.reporting.MavenReportException;
25  
26  /**
27   * A reporting task that performs Checkstyle analysis and generates an aggregate
28   * HTML report on the violations that Checkstyle finds in a multi-module reactor
29   * build.
30   *
31   *
32   */
33  @Mojo(
34          name = "checkstyle-aggregate",
35          aggregator = true,
36          requiresDependencyResolution = ResolutionScope.COMPILE,
37          threadSafe = true)
38  public class CheckstyleAggregateReport extends AbstractCheckstyleReport {
39      /**
40       * {@inheritDoc}
41       */
42      protected CheckstyleExecutorRequest createRequest() throws MavenReportException {
43          CheckstyleExecutorRequest request = new CheckstyleExecutorRequest();
44          request.setAggregate(true)
45                  .setReactorProjects(reactorProjects)
46                  .setConsoleListener(getConsoleListener())
47                  .setConsoleOutput(consoleOutput)
48                  .setExcludes(excludes)
49                  .setFailsOnError(failsOnError)
50                  .setIncludes(includes)
51                  .setResourceIncludes(resourceIncludes)
52                  .setResourceExcludes(resourceExcludes)
53                  .setIncludeResources(includeResources)
54                  .setIncludeTestResources(includeTestResources)
55                  .setIncludeTestSourceDirectory(includeTestSourceDirectory)
56                  .setListener(getListener())
57                  .setProject(project)
58                  .setSourceDirectories(getSourceDirectories())
59                  .setResources(resources)
60                  .setTestResources(testResources)
61                  .setStringOutputStream(stringOutputStream)
62                  .setSuppressionsLocation(suppressionsLocation)
63                  .setTestSourceDirectories(getTestSourceDirectories())
64                  .setPropertyExpansion(propertyExpansion)
65                  .setHeaderLocation(headerLocation)
66                  .setCacheFile(cacheFile)
67                  .setSuppressionsFileExpression(suppressionsFileExpression)
68                  .setEncoding(getInputEncoding())
69                  .setPropertiesLocation(propertiesLocation);
70          return request;
71      }
72  
73      /** {@inheritDoc} */
74      public String getOutputName() {
75          return "checkstyle-aggregate";
76      }
77  
78      /** {@inheritDoc} */
79      public boolean canGenerateReport() {
80          // TODO: would be good to scan the files here
81          return !skip && project.isExecutionRoot() && reactorProjects.size() > 1;
82      }
83  }