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