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.exec;
20  
21  import java.io.ByteArrayOutputStream;
22  import java.io.File;
23  import java.util.Collection;
24  import java.util.List;
25  
26  import com.puppycrawl.tools.checkstyle.DefaultLogger;
27  import com.puppycrawl.tools.checkstyle.api.AuditListener;
28  import org.apache.maven.artifact.Artifact;
29  import org.apache.maven.model.Resource;
30  import org.apache.maven.project.MavenProject;
31  
32  /**
33   * @author Olivier Lamy
34   * @since 2.5
35   *
36   */
37  public class CheckstyleExecutorRequest {
38  
39      /**
40       * Specifies the names filter of the source files to be used for Checkstyle.
41       */
42      private String includes;
43  
44      /**
45       * Specifies the names filter of the source files to be excluded for Checkstyle.
46       */
47      private String excludes;
48  
49      /**
50       * Specifies names filter for resources.
51       */
52      private String resourceIncludes;
53  
54      /**
55       * Specifies names filter for resources.
56       */
57      private String resourceExcludes;
58  
59      private MavenProject project;
60  
61      private String suppressionsLocation;
62  
63      private boolean includeTestSourceDirectory;
64  
65      private Collection<File> testSourceDirectories;
66  
67      private Collection<File> sourceDirectories;
68  
69      private boolean includeResources;
70  
71      private boolean includeTestResources;
72  
73      private List<Resource> resources;
74  
75      private List<Resource> testResources;
76  
77      private boolean failsOnError;
78  
79      private AuditListener listener;
80  
81      private boolean consoleOutput;
82  
83      private DefaultLogger defaultLogger;
84  
85      private ByteArrayOutputStream stringOutputStream;
86  
87      private String propertiesLocation;
88  
89      //
90  
91      private String configLocation;
92  
93      private String propertyExpansion;
94  
95      private String headerLocation;
96  
97      private String cacheFile;
98  
99      private String suppressionsFileExpression;
100 
101     private String encoding;
102 
103     /**
104      * @since 2.8
105      */
106     private boolean aggregate = false;
107 
108     /**
109      * @since 2.8
110      */
111     private List<MavenProject> reactorProjects;
112 
113     /**
114      * @since 2.12.1
115      */
116     private List<Artifact> licenseArtifacts;
117 
118     /**
119      * @since 2.12.1
120      */
121     private List<Artifact> configurationArtifacts;
122 
123     /**
124      * @since 3.0.0
125      */
126     private boolean omitIgnoredModules;
127 
128     /**
129      * Constructor.
130      */
131     public CheckstyleExecutorRequest() {
132         // nothing
133     }
134 
135     /**
136      * Returns the includes parameter.
137      *
138      * @return The includes parameter.
139      */
140     public String getIncludes() {
141         return includes;
142     }
143 
144     public CheckstyleExecutorRequest setIncludes(String includes) {
145         this.includes = includes;
146         return this;
147     }
148 
149     public String getExcludes() {
150         return excludes;
151     }
152 
153     public CheckstyleExecutorRequest setExcludes(String excludes) {
154         this.excludes = excludes;
155         return this;
156     }
157 
158     public String getResourceIncludes() {
159         return resourceIncludes;
160     }
161 
162     public CheckstyleExecutorRequest setResourceIncludes(String resourceIncludes) {
163         this.resourceIncludes = resourceIncludes;
164         return this;
165     }
166 
167     public String getResourceExcludes() {
168         return resourceExcludes;
169     }
170 
171     public CheckstyleExecutorRequest setResourceExcludes(String resourceExcludes) {
172         this.resourceExcludes = resourceExcludes;
173         return this;
174     }
175 
176     public MavenProject getProject() {
177         return project;
178     }
179 
180     public CheckstyleExecutorRequest setProject(MavenProject project) {
181         this.project = project;
182         return this;
183     }
184 
185     public String getSuppressionsLocation() {
186         return suppressionsLocation;
187     }
188 
189     public CheckstyleExecutorRequest setSuppressionsLocation(String suppressionsLocation) {
190         this.suppressionsLocation = suppressionsLocation;
191         return this;
192     }
193 
194     public boolean isIncludeTestSourceDirectory() {
195         return includeTestSourceDirectory;
196     }
197 
198     public CheckstyleExecutorRequest setIncludeTestSourceDirectory(boolean includeTestSourceDirectory) {
199         this.includeTestSourceDirectory = includeTestSourceDirectory;
200         return this;
201     }
202 
203     public Collection<File> getTestSourceDirectories() {
204         return testSourceDirectories;
205     }
206 
207     public CheckstyleExecutorRequest setTestSourceDirectories(Collection<File> testSourceDirectories) {
208         this.testSourceDirectories = testSourceDirectories;
209         return this;
210     }
211 
212     public Collection<File> getSourceDirectories() {
213         return sourceDirectories;
214     }
215 
216     public CheckstyleExecutorRequest setSourceDirectories(Collection<File> sourceDirectories) {
217         this.sourceDirectories = sourceDirectories;
218         return this;
219     }
220 
221     public List<Resource> getResources() {
222         return resources;
223     }
224 
225     public CheckstyleExecutorRequest setResources(List<Resource> resources) {
226         this.resources = resources;
227         return this;
228     }
229 
230     public List<Resource> getTestResources() {
231         return testResources;
232     }
233 
234     public CheckstyleExecutorRequest setTestResources(List<Resource> testResources) {
235         this.testResources = testResources;
236         return this;
237     }
238 
239     public boolean isFailsOnError() {
240         return failsOnError;
241     }
242 
243     public CheckstyleExecutorRequest setFailsOnError(boolean failsOnError) {
244         this.failsOnError = failsOnError;
245         return this;
246     }
247 
248     public AuditListener getListener() {
249         return listener;
250     }
251 
252     public CheckstyleExecutorRequest setListener(AuditListener listener) {
253         this.listener = listener;
254         return this;
255     }
256 
257     public boolean isConsoleOutput() {
258         return consoleOutput;
259     }
260 
261     public CheckstyleExecutorRequest setConsoleOutput(boolean consoleOutput) {
262         this.consoleOutput = consoleOutput;
263         return this;
264     }
265 
266     public CheckstyleExecutorRequest setConsoleListener(DefaultLogger defaultLogger) {
267         this.defaultLogger = defaultLogger;
268         return this;
269     }
270 
271     public DefaultLogger getConsoleListener() {
272         return this.defaultLogger;
273     }
274 
275     public ByteArrayOutputStream getStringOutputStream() {
276         return stringOutputStream;
277     }
278 
279     public CheckstyleExecutorRequest setStringOutputStream(ByteArrayOutputStream stringOutputStream) {
280         this.stringOutputStream = stringOutputStream;
281         return this;
282     }
283 
284     public String getConfigLocation() {
285         return configLocation;
286     }
287 
288     public CheckstyleExecutorRequest setConfigLocation(String configLocation) {
289         this.configLocation = configLocation;
290         return this;
291     }
292 
293     public String getPropertyExpansion() {
294         return propertyExpansion;
295     }
296 
297     public CheckstyleExecutorRequest setPropertyExpansion(String propertyExpansion) {
298         this.propertyExpansion = propertyExpansion;
299         return this;
300     }
301 
302     public String getHeaderLocation() {
303         return headerLocation;
304     }
305 
306     public CheckstyleExecutorRequest setHeaderLocation(String headerLocation) {
307         this.headerLocation = headerLocation;
308         return this;
309     }
310 
311     public String getCacheFile() {
312         return cacheFile;
313     }
314 
315     public CheckstyleExecutorRequest setCacheFile(String cacheFile) {
316         this.cacheFile = cacheFile;
317         return this;
318     }
319 
320     public String getSuppressionsFileExpression() {
321         return suppressionsFileExpression;
322     }
323 
324     public CheckstyleExecutorRequest setSuppressionsFileExpression(String suppressionsFileExpression) {
325         this.suppressionsFileExpression = suppressionsFileExpression;
326         return this;
327     }
328 
329     public String getEncoding() {
330         return encoding;
331     }
332 
333     public CheckstyleExecutorRequest setEncoding(String encoding) {
334         this.encoding = encoding;
335         return this;
336     }
337 
338     public String getPropertiesLocation() {
339         return propertiesLocation;
340     }
341 
342     public CheckstyleExecutorRequest setPropertiesLocation(String propertiesLocation) {
343         this.propertiesLocation = propertiesLocation;
344         return this;
345     }
346 
347     /**
348      * Returns true if the report is aggregated.
349      *
350      * @return <code>true</code> if the report is aggregated.
351      */
352     public boolean isAggregate() {
353         return aggregate;
354     }
355 
356     /**
357      * Sets the aggregate parameter.
358      *
359      * @param pAggregate <code>true</code> if an aggregated report is desired.
360      * @return This object.
361      */
362     public CheckstyleExecutorRequest setAggregate(boolean pAggregate) {
363         this.aggregate = pAggregate;
364         return this;
365     }
366 
367     /**
368      * Returns the list of reactor projects.
369      *
370      * @return The reactor projects.
371      */
372     public List<MavenProject> getReactorProjects() {
373         return reactorProjects;
374     }
375 
376     /**
377      * Sets the list of reactor projects.
378      *
379      * @param pReactorProjects The reactor projects.
380      * @return This object.
381      */
382     public CheckstyleExecutorRequest setReactorProjects(List<MavenProject> pReactorProjects) {
383         this.reactorProjects = pReactorProjects;
384         return this;
385     }
386 
387     /**
388      * Returns a list of license artifacts, which may contain the license.
389      *
390      * @return the license artifacts
391      */
392     public List<Artifact> getLicenseArtifacts() {
393         return licenseArtifacts;
394     }
395 
396     /**
397      * Sets a list of license artifacts, which may contain the license.
398      *
399      * @param licenseArtifacts List of license artifacts.
400      * @return This object.
401      */
402     public CheckstyleExecutorRequest setLicenseArtifacts(List<Artifact> licenseArtifacts) {
403         this.licenseArtifacts = licenseArtifacts;
404         return this;
405     }
406 
407     /**
408      * Returns a list of artifacts, which may contain the checkstyle configuration.
409      *
410      * @return the license artifacts
411      */
412     public List<Artifact> getConfigurationArtifacts() {
413         return configurationArtifacts;
414     }
415 
416     /**
417      * Sets a list of artifacts, which may contain the checkstyle configuration.
418      *
419      * @param configArtifacts List of artifacts.
420      * @return This object.
421      */
422     public CheckstyleExecutorRequest setConfigurationArtifacts(List<Artifact> configArtifacts) {
423         this.configurationArtifacts = configArtifacts;
424         return this;
425     }
426 
427     public boolean isIncludeResources() {
428         return includeResources;
429     }
430 
431     /**
432      * @param includeResources whether to include the resource directories in the checks.
433      * @return This object.
434      */
435     public CheckstyleExecutorRequest setIncludeResources(boolean includeResources) {
436         this.includeResources = includeResources;
437         return this;
438     }
439 
440     public boolean isIncludeTestResources() {
441         return includeTestResources;
442     }
443 
444     /**
445      * @param includeTestResources whether to set the test resource directories in the checks.
446      * @return This object.
447      */
448     public CheckstyleExecutorRequest setIncludeTestResources(boolean includeTestResources) {
449         this.includeTestResources = includeTestResources;
450         return this;
451     }
452 
453     /**
454      * Returns true if ignored modules (modules with severity 'ignore') should be omitted.
455      *
456      * @return <code>true</code> if ignored modules should be omitted.
457      */
458     public boolean isOmitIgnoredModules() {
459         return omitIgnoredModules;
460     }
461 
462     /**
463      * @param omitIgnoredModules Whether to omit ignored modules (modules with severity 'ignore').
464      * @return This object.
465      */
466     public CheckstyleExecutorRequest setOmitIgnoredModules(boolean omitIgnoredModules) {
467         this.omitIgnoredModules = omitIgnoredModules;
468         return this;
469     }
470 }