1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugins.checkstyle;
20
21 import java.util.List;
22
23 import org.apache.maven.plugins.annotations.Mojo;
24 import org.apache.maven.plugins.annotations.Parameter;
25 import org.apache.maven.plugins.annotations.ResolutionScope;
26 import org.apache.maven.plugins.checkstyle.exec.CheckstyleExecutorRequest;
27 import org.apache.maven.project.MavenProject;
28 import org.apache.maven.reporting.MavenReportException;
29
30
31
32
33
34
35
36
37 @Mojo(
38 name = "checkstyle-aggregate",
39 aggregator = true,
40 requiresDependencyResolution = ResolutionScope.COMPILE,
41 threadSafe = true)
42 public class CheckstyleAggregateReport extends AbstractCheckstyleReport {
43
44
45
46
47
48 @Parameter(property = "reactorProjects", readonly = true)
49 private List<MavenProject> reactorProjects;
50
51
52 protected MavenProject getProject() {
53 return project;
54 }
55
56
57
58
59 protected CheckstyleExecutorRequest createRequest() throws MavenReportException {
60 CheckstyleExecutorRequest request = new CheckstyleExecutorRequest();
61 request.setAggregate(true)
62 .setReactorProjects(reactorProjects)
63 .setConsoleListener(getConsoleListener())
64 .setConsoleOutput(consoleOutput)
65 .setExcludes(excludes)
66 .setFailsOnError(failsOnError)
67 .setIncludes(includes)
68 .setResourceIncludes(resourceIncludes)
69 .setResourceExcludes(resourceExcludes)
70 .setIncludeResources(includeResources)
71 .setIncludeTestResources(includeTestResources)
72 .setIncludeTestSourceDirectory(includeTestSourceDirectory)
73 .setListener(getListener())
74 .setProject(project)
75 .setSourceDirectories(getSourceDirectories())
76 .setResources(resources)
77 .setTestResources(testResources)
78 .setStringOutputStream(stringOutputStream)
79 .setSuppressionsLocation(suppressionsLocation)
80 .setTestSourceDirectories(getTestSourceDirectories())
81 .setPropertyExpansion(propertyExpansion)
82 .setHeaderLocation(headerLocation)
83 .setCacheFile(cacheFile)
84 .setSuppressionsFileExpression(suppressionsFileExpression)
85 .setEncoding(getInputEncoding())
86 .setPropertiesLocation(propertiesLocation);
87 return request;
88 }
89
90
91 public String getOutputName() {
92 return "checkstyle-aggregate";
93 }
94
95
96 public boolean canGenerateReport() {
97
98 return !skip && project.isExecutionRoot() && reactorProjects.size() > 1;
99 }
100 }