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