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