View Javadoc

1   /*
2   	StatCvs - CVS statistics generation 
3   	Copyright (C) 2002  Lukasz Pekacki <lukasz@pekacki.de>
4   	http://statcvs.sf.net/
5       
6   	This library is free software; you can redistribute it and/or
7   	modify it under the terms of the GNU Lesser General Public
8   	License as published by the Free Software Foundation; either
9   	version 2.1 of the License, or (at your option) any later version.
10  
11  	This library is distributed in the hope that it will be useful,
12  	but WITHOUT ANY WARRANTY; without even the implied warranty of
13  	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  	Lesser General Public License for more details.
15  
16  	You should have received a copy of the GNU Lesser General Public
17  	License along with this library; if not, write to the Free Software
18  	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19      
20  	$RCSfile: StatCvsTask.java,v $
21  	$Date: 2009/06/02 15:35:43 $ 
22  */
23  package net.sf.statcvs.ant;
24  
25  import java.io.IOException;
26  
27  import net.sf.statcvs.Main;
28  import net.sf.statcvs.input.LogSyntaxException;
29  import net.sf.statcvs.output.ConfigurationException;
30  import net.sf.statcvs.output.ConfigurationOptions;
31  
32  import org.apache.tools.ant.BuildException;
33  import org.apache.tools.ant.Task;
34  
35  /**
36   * Ant task for running statcvs. 
37   * 
38   * @author Andy Glover
39   * @author Richard Cyganiak
40   */
41  public class StatCvsTask extends Task {
42      private String title;
43      private String logFile;
44      private String pDir;
45      private String outDir;
46      private String cssFile;
47      private String notesFile;
48      private String viewcvs;
49      private String viewvc;
50      private String cvsweb;
51      private String chora;
52      private String jcvsweb;
53      private String bugzilla;
54      private String mantis;
55      private String include = null;
56      private String exclude = null;
57      private String tags;
58      private String format;
59      private String nonDeveloperLogin;
60      private String charset;
61      private String configFile;
62      private boolean disableTwitterButton = false;
63      
64      /**
65       * Constructor for StatCvsTask.
66       */
67      public StatCvsTask() {
68          super();
69      }
70  
71      /**
72       * Runs the task
73       * @throws BuildException if an IO Error occurs
74       */
75      public void execute() throws BuildException {
76          try {
77              this.initProperties();
78              Main.generateDefaultHTMLSuite();
79          } catch (final ConfigurationException e) {
80              throw new BuildException(e.getMessage());
81          } catch (final IOException e) {
82              throw new BuildException(e.getMessage());
83          } catch (final LogSyntaxException e) {
84              throw new BuildException(e.getMessage());
85          }
86      }
87  
88      /**
89       * method initializes the ConfigurationOptions object with
90       * received values. 
91       */
92      protected void initProperties() throws ConfigurationException {
93  
94          // required params
95          ConfigurationOptions.setLogFileName(this.logFile);
96          ConfigurationOptions.setCheckedOutDirectory(this.pDir);
97  
98          // optional params
99          if (this.title != null) {
100             ConfigurationOptions.setProjectName(this.title);
101         }
102         if (this.outDir != null) {
103             ConfigurationOptions.setOutputDir(this.outDir);
104         }
105         if (cssFile != null) {
106             ConfigurationOptions.setCssFile(this.cssFile);
107         }
108         if (notesFile != null) {
109             ConfigurationOptions.setNotesFile(this.notesFile);
110         }
111         if (viewcvs != null) {
112             ConfigurationOptions.setViewCvsURL(this.viewcvs);
113         }
114         if (viewvc != null) {
115             ConfigurationOptions.setViewVcURL(this.viewvc);
116         }
117         if (cvsweb != null) {
118             ConfigurationOptions.setCvswebURL(this.cvsweb);
119         }
120         if (chora != null) {
121             ConfigurationOptions.setChoraURL(this.chora);
122         }
123         if (jcvsweb != null) {
124             ConfigurationOptions.setJCVSWebURL(this.jcvsweb);
125         }
126         if (bugzilla != null) {
127             ConfigurationOptions.setBugzillaUrl(this.bugzilla);
128         }
129         if (mantis != null) {
130             ConfigurationOptions.setMantisUrl(this.mantis);
131         }
132         if (include != null) {
133             ConfigurationOptions.setIncludePattern(this.include);
134         }
135         if (exclude != null) {
136             ConfigurationOptions.setExcludePattern(this.exclude);
137         }
138         if (tags != null) {
139             ConfigurationOptions.setSymbolicNamesPattern(this.tags);
140         }
141         if (format != null) {
142             ConfigurationOptions.setOutputFormat(this.format);
143         }
144         if (charset != null) {
145             ConfigurationOptions.setCharSet(this.charset);
146         }
147         if (nonDeveloperLogin != null) {
148             ConfigurationOptions.addNonDeveloperLogin(this.nonDeveloperLogin);
149         }
150         if (configFile != null) {
151             ConfigurationOptions.setConfigFile(this.configFile);
152         }
153         ConfigurationOptions.setEnableTwitterButton(!disableTwitterButton);
154     }
155 
156     /**
157      * @param logFile String representing the cvs log file
158      */
159     public void setLog(final String logFile) {
160         this.logFile = logFile;
161     }
162 
163     /**
164      * @param modDir String representing the directory containing the CVS project
165      */
166     public void setPath(final String modDir) {
167         this.pDir = modDir;
168     }
169 
170     /**
171      * @param outDir String representing the output directory of the report
172      */
173     public void setOutputDir(final String outDir) {
174         this.outDir = outDir;
175     }
176 
177     /**
178      * Specifies files to include in the analysis.
179      * @param include a list of Ant-style wildcard patterns, delimited by : or ;
180      * @see net.sf.statcvs.util.FilePatternMatcher
181      */
182     public void setInclude(final String include) {
183         this.include = include;
184     }
185 
186     /**
187      * Specifies files to exclude from the analysis.
188      * @param exclude a list of Ant-style wildcard patterns, delimited by : or ;
189      * @see net.sf.statcvs.util.FilePatternMatcher
190      */
191     public void setExclude(final String exclude) {
192         this.exclude = exclude;
193     }
194 
195     /**
196      * Specifies regular expression to include tag to lines
197      * of code graph.
198      * @param tags regular expression to included tags names.
199      */
200     public void setTags(final String tags) {
201         this.tags = tags;
202     }
203 
204     /**
205      * @param title String representing the title to be used in the reports
206      */
207     public void setTitle(final String title) {
208         this.title = title;
209     }
210 
211     /**
212      * @param cssFile String representing the CSS file to use for the report
213      */
214     public void setCss(final String cssFile) {
215         this.cssFile = cssFile;
216     }
217 
218     /**
219      * @param notesFile String representing the notes file to include on
220      * the report's index page
221      */
222     public void setNotes(final String notesFile) {
223         this.notesFile = notesFile;
224     }
225 
226     /**
227      * @param viewcvs String representing the URL of a ViewCVS installation
228      */
229     public void setViewCVS(final String viewcvs) {
230         this.viewcvs = viewcvs;
231     }
232 
233     /**
234      * @param viewvc String representing the URL of a ViewVC installation
235      */
236     public void setViewVC(final String viewvc) {
237         this.viewvc = viewvc;
238     }
239 
240     /**
241      * @param cvsweb String representing the URL of a cvsweb installation
242      */
243     public void setCvsweb(final String cvsweb) {
244         this.cvsweb = cvsweb;
245     }
246 
247     /**
248      * @param chora String representing the URL of a Chora installation
249      */
250     public void setChora(final String chora) {
251         this.chora = chora;
252     }
253 
254     /**
255      * @param jcvsweb String representing the URL of a JCVSWeb installation
256      */
257     public void setJCVSWeb(final String jcvsweb) {
258         this.jcvsweb = jcvsweb;
259     }
260 
261     /**
262      * @param bugzilla String representing the URL of a Bugzilla installation
263      */
264     public void setBugzilla(final String bugzilla) {
265         this.bugzilla = bugzilla;
266     }
267 
268     /**
269      * @param mantis String representing the URL of a Mantis installation
270      */
271     public void setMantis(final String mantis) {
272         this.mantis = mantis;
273     }
274 
275     /**
276      * @param generateXDoc Generate XDoc or HTML?
277      */
278     public void setXDoc(final boolean generateXDoc) {
279         this.format = generateXDoc ? "xdoc" : "html";
280     }
281 
282     /**
283      * @param format "<tt>xdoc</tt>" or "<tt>html</tt>"
284      */
285     public void setFormat(final String format) {
286         this.format = format;
287     }
288 
289     /**
290      * TODO: This supports just a single value, but should support multiple
291      *       login names -- how?
292      * @param nonDeveloperLogin A login name to be excluded from developer
293      * 		lists
294      */
295     public void setNoDeveloper(final String nonDeveloperLogin) {
296         this.nonDeveloperLogin = nonDeveloperLogin;
297     }
298 
299     public void setCharset(final String charset) {
300         this.charset = charset;
301     }
302 
303     public void setConfigFile(String configFile) {
304         this.configFile = configFile;
305     }
306 
307     public void setDisableTwitterButton(boolean disableTwitterButton) {
308         this.disableTwitterButton = disableTwitterButton;
309     }
310 }