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/03/09 21:45:42 $ 
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  
62      /**
63       * Constructor for StatCvsTask.
64       */
65      public StatCvsTask() {
66          super();
67      }
68  
69      /**
70       * Runs the task
71       * @throws BuildException if an IO Error occurs
72       */
73      public void execute() throws BuildException {
74          try {
75              this.initProperties();
76              Main.generateDefaultHTMLSuite();
77          } catch (final ConfigurationException e) {
78              throw new BuildException(e.getMessage());
79          } catch (final IOException e) {
80              throw new BuildException(e.getMessage());
81          } catch (final LogSyntaxException e) {
82              throw new BuildException(e.getMessage());
83          }
84      }
85  
86      /**
87       * method initializes the ConfigurationOptions object with
88       * received values. 
89       */
90      protected void initProperties() throws ConfigurationException {
91  
92          // required params
93          ConfigurationOptions.setLogFileName(this.logFile);
94          ConfigurationOptions.setCheckedOutDirectory(this.pDir);
95  
96          // optional params
97          if (this.title != null) {
98              ConfigurationOptions.setProjectName(this.title);
99          }
100         if (this.outDir != null) {
101             ConfigurationOptions.setOutputDir(this.outDir);
102         }
103         if (cssFile != null) {
104             ConfigurationOptions.setCssFile(this.cssFile);
105         }
106         if (notesFile != null) {
107             ConfigurationOptions.setNotesFile(this.notesFile);
108         }
109         if (viewcvs != null) {
110             ConfigurationOptions.setViewCvsURL(this.viewcvs);
111         }
112         if (viewvc != null) {
113             ConfigurationOptions.setViewVcURL(this.viewvc);
114         }
115         if (cvsweb != null) {
116             ConfigurationOptions.setCvswebURL(this.cvsweb);
117         }
118         if (chora != null) {
119             ConfigurationOptions.setChoraURL(this.chora);
120         }
121         if (jcvsweb != null) {
122             ConfigurationOptions.setJCVSWebURL(this.jcvsweb);
123         }
124         if (bugzilla != null) {
125             ConfigurationOptions.setBugzillaUrl(this.bugzilla);
126         }
127         if (mantis != null) {
128             ConfigurationOptions.setMantisUrl(this.mantis);
129         }
130         if (include != null) {
131             ConfigurationOptions.setIncludePattern(this.include);
132         }
133         if (exclude != null) {
134             ConfigurationOptions.setExcludePattern(this.exclude);
135         }
136         if (tags != null) {
137             ConfigurationOptions.setSymbolicNamesPattern(this.tags);
138         }
139         if (format != null) {
140             ConfigurationOptions.setOutputFormat(this.format);
141         }
142         if (charset != null) {
143             ConfigurationOptions.setCharSet(this.charset);
144         }
145         if (nonDeveloperLogin != null) {
146             ConfigurationOptions.addNonDeveloperLogin(this.nonDeveloperLogin);
147         }
148     }
149 
150     /**
151      * @param logFile String representing the cvs log file
152      */
153     public void setLog(final String logFile) {
154         this.logFile = logFile;
155     }
156 
157     /**
158      * @param modDir String representing the directory containing the CVS project
159      */
160     public void setPath(final String modDir) {
161         this.pDir = modDir;
162     }
163 
164     /**
165      * @param outDir String representing the output directory of the report
166      */
167     public void setOutputDir(final String outDir) {
168         this.outDir = outDir;
169     }
170 
171     /**
172      * Specifies files to include in the analysis.
173      * @param include a list of Ant-style wildcard patterns, delimited by : or ;
174      * @see net.sf.statcvs.util.FilePatternMatcher
175      */
176     public void setInclude(final String include) {
177         this.include = include;
178     }
179 
180     /**
181      * Specifies files to exclude from the analysis.
182      * @param exclude a list of Ant-style wildcard patterns, delimited by : or ;
183      * @see net.sf.statcvs.util.FilePatternMatcher
184      */
185     public void setExclude(final String exclude) {
186         this.exclude = exclude;
187     }
188 
189     /**
190      * Specifies regular expression to include tag to lines
191      * of code graph.
192      * @param tags regular expression to included tags names.
193      */
194     public void setTags(final String tags) {
195         this.tags = tags;
196     }
197 
198     /**
199      * @param title String representing the title to be used in the reports
200      */
201     public void setTitle(final String title) {
202         this.title = title;
203     }
204 
205     /**
206      * @param cssFile String representing the CSS file to use for the report
207      */
208     public void setCss(final String cssFile) {
209         this.cssFile = cssFile;
210     }
211 
212     /**
213      * @param notesFile String representing the notes file to include on
214      * the report's index page
215      */
216     public void setNotes(final String notesFile) {
217         this.notesFile = notesFile;
218     }
219 
220     /**
221      * @param viewcvs String representing the URL of a ViewCVS installation
222      */
223     public void setViewCVS(final String viewcvs) {
224         this.viewcvs = viewcvs;
225     }
226 
227     /**
228      * @param viewvc String representing the URL of a ViewVC installation
229      */
230     public void setViewVC(final String viewvc) {
231         this.viewvc = viewvc;
232     }
233 
234     /**
235      * @param cvsweb String representing the URL of a cvsweb installation
236      */
237     public void setCvsweb(final String cvsweb) {
238         this.cvsweb = cvsweb;
239     }
240 
241     /**
242      * @param chora String representing the URL of a Chora installation
243      */
244     public void setChora(final String chora) {
245         this.chora = chora;
246     }
247 
248     /**
249      * @param jcvsweb String representing the URL of a JCVSWeb installation
250      */
251     public void setJCVSWeb(final String jcvsweb) {
252         this.jcvsweb = jcvsweb;
253     }
254 
255     /**
256      * @param bugzilla String representing the URL of a Bugzilla installation
257      */
258     public void setBugzilla(final String bugzilla) {
259         this.bugzilla = bugzilla;
260     }
261 
262     /**
263      * @param mantis String representing the URL of a Mantis installation
264      */
265     public void setMantis(final String mantis) {
266         this.mantis = mantis;
267     }
268 
269     /**
270      * @param generateXDoc Generate XDoc or HTML?
271      */
272     public void setXDoc(final boolean generateXDoc) {
273         this.format = generateXDoc ? "xdoc" : "html";
274     }
275 
276     /**
277      * @param format "<tt>xdoc</tt>" or "<tt>html</tt>"
278      */
279     public void setFormat(final String format) {
280         this.format = format;
281     }
282 
283     /**
284      * TODO: This supports just a single value, but should support multiple
285      *       login names -- how?
286      * @param nonDeveloperLogin A login name to be excluded from developer
287      * 		lists
288      */
289     public void setNoDeveloper(final String nonDeveloperLogin) {
290         this.nonDeveloperLogin = nonDeveloperLogin;
291     }
292 
293     public void setCharset(final String charset) {
294         this.charset = charset;
295     }
296 }