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