View Javadoc
1   package org.apache.maven.plugins.pmd.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.File;
23  import java.io.Serializable;
24  import java.util.ArrayList;
25  import java.util.Collection;
26  import java.util.List;
27  
28  /**
29   * Data object to store all configuration options needed to execute PMD
30   * as a separate process.
31   * 
32   * <p>This class is intended to be serialized and read back.
33   * 
34   * <p>Some properties might be optional and can be <code>null</code>.
35   */
36  public class PmdRequest implements Serializable
37  {
38      private static final long serialVersionUID = -6324416880563476455L;
39  
40      private String javaExecutable;
41  
42      private String language;
43      private String languageVersion;
44      private int minimumPriority;
45      private String auxClasspath;
46      private String suppressMarker;
47      private String analysisCacheLocation;
48      private String rulesets;
49      private String sourceEncoding;
50      private List<File> files = new ArrayList<>();
51  
52      private boolean showPmdLog;
53      private boolean colorizedLog;
54      private String logLevel;
55      private boolean skipPmdError;
56  
57      private String excludeFromFailureFile;
58      private String targetDirectory;
59      private String outputEncoding;
60      private String format;
61      private String benchmarkOutputLocation;
62      private boolean includeXmlInSite;
63      private String reportOutputDirectory;
64  
65      /**
66       * Configure language and language version.
67       *
68       * @param language the language
69       * @param targetJdk the language version, optional, can be <code>null</code>
70       */
71      public void setLanguageAndVersion( String language, String targetJdk )
72      {
73          if ( "java".equals( language ) || null == language )
74          {
75              this.language = "java";
76              this.languageVersion = targetJdk;
77          }
78          else if ( "javascript".equals( language ) || "ecmascript".equals( language ) )
79          {
80              this.language = "ecmascript";
81          }
82          else if ( "jsp".equals( language ) )
83          {
84              this.language = "jsp";
85          }
86          else
87          {
88              this.language = language;
89          }
90      }
91  
92      public void setJavaExecutable( String javaExecutable )
93      {
94          this.javaExecutable = javaExecutable;
95      }
96  
97      public void setMinimumPriority( int minimumPriority )
98      {
99          this.minimumPriority = minimumPriority;
100     }
101 
102     public void setAuxClasspath( String auxClasspath )
103     {
104         this.auxClasspath = auxClasspath;
105     }
106 
107     public void setSuppressMarker( String suppressMarker )
108     {
109         this.suppressMarker = suppressMarker;
110     }
111 
112     public void setAnalysisCacheLocation( String analysisCacheLocation )
113     {
114         this.analysisCacheLocation = analysisCacheLocation;
115     }
116 
117     public void setRulesets( String rulesets )
118     {
119         this.rulesets = rulesets;
120     }
121 
122     public void setSourceEncoding( String sourceEncoding )
123     {
124         this.sourceEncoding = sourceEncoding;
125     }
126 
127     public void addFiles( Collection<File> files )
128     {
129         this.files.addAll( files );
130     }
131 
132     public void setBenchmarkOutputLocation( String benchmarkOutputLocation )
133     {
134         this.benchmarkOutputLocation = benchmarkOutputLocation;
135     }
136 
137     public void setTargetDirectory( String targetDirectory )
138     {
139         this.targetDirectory = targetDirectory;
140     }
141 
142     public void setOutputEncoding( String outputEncoding )
143     {
144         this.outputEncoding = outputEncoding;
145     }
146 
147     public void setFormat( String format )
148     {
149         this.format = format;
150     }
151 
152     public void setShowPmdLog( boolean showPmdLog )
153     {
154         this.showPmdLog = showPmdLog;
155     }
156 
157     public void setColorizedLog( boolean colorizedLog )
158     {
159         this.colorizedLog = colorizedLog;
160     }
161 
162     public void setLogLevel( String logLevel )
163     {
164         this.logLevel = logLevel;
165     }
166 
167     public void setSkipPmdError( boolean skipPmdError )
168     {
169         this.skipPmdError = skipPmdError;
170     }
171 
172     public void setIncludeXmlInSite( boolean includeXmlInSite )
173     {
174         this.includeXmlInSite = includeXmlInSite;
175     }
176 
177     public void setReportOutputDirectory( String reportOutputDirectory )
178     {
179         this.reportOutputDirectory = reportOutputDirectory;
180     }
181 
182     public void setExcludeFromFailureFile( String excludeFromFailureFile )
183     {
184         this.excludeFromFailureFile = excludeFromFailureFile;
185     }
186 
187 
188 
189 
190 
191     public String getJavaExecutable()
192     {
193         return javaExecutable;
194     }
195 
196     public String getLanguage()
197     {
198         return language;
199     }
200 
201     public String getLanguageVersion()
202     {
203         return languageVersion;
204     }
205 
206     public int getMinimumPriority()
207     {
208         return minimumPriority;
209     }
210 
211     public String getAuxClasspath()
212     {
213         return auxClasspath;
214     }
215 
216     public String getSuppressMarker()
217     {
218         return suppressMarker;
219     }
220 
221     public String getAnalysisCacheLocation()
222     {
223         return analysisCacheLocation;
224     }
225 
226     public String getRulesets()
227     {
228         return rulesets;
229     }
230 
231     public String getSourceEncoding()
232     {
233         return sourceEncoding;
234     }
235 
236     public List<File> getFiles()
237     {
238         return files;
239     }
240 
241     public String getBenchmarkOutputLocation()
242     {
243         return benchmarkOutputLocation;
244     }
245 
246     public String getTargetDirectory()
247     {
248         return targetDirectory;
249     }
250 
251     public String getOutputEncoding()
252     {
253         return outputEncoding;
254     }
255 
256     public String getFormat()
257     {
258         return format;
259     }
260 
261     public boolean isShowPmdLog()
262     {
263         return showPmdLog;
264     }
265 
266     public boolean isColorizedLog()
267     {
268         return colorizedLog;
269     }
270 
271     public String getLogLevel()
272     {
273         return logLevel;
274     }
275 
276     public boolean isDebugEnabled()
277     {
278         return "debug".equals( logLevel );
279     }
280 
281     public boolean isSkipPmdError()
282     {
283         return skipPmdError;
284     }
285 
286     public boolean isIncludeXmlInSite()
287     {
288         return includeXmlInSite;
289     }
290 
291     public String getReportOutputDirectory()
292     {
293         return reportOutputDirectory;
294     }
295 
296     public String getExcludeFromFailureFile()
297     {
298         return excludeFromFailureFile;
299     }
300 }