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: StatSvnTask.java,v $ 21 $Date: 2005/03/24 00:19:51 $ 22 */ 23 package net.sf.statsvn.ant; 24 25 import net.sf.statcvs.ant.StatCvsTask; 26 import net.sf.statcvs.output.ConfigurationException; 27 import net.sf.statsvn.Main; 28 import net.sf.statsvn.output.SvnConfigurationOptions; 29 30 /** 31 * Ant task for running StatSVN. 32 * 33 * @author Andy Glover 34 * @author Richard Cyganiak 35 * @author Benoit Xhenseval 36 * @author Jason Kealey 37 */ 38 public class StatSvnTask extends StatCvsTask { 39 40 private boolean anonymize = false; 41 42 private String cacheDirectory; 43 44 private String svnPassword; 45 46 private String svnUsername; 47 48 private int numberSvnDiffThreads; 49 50 private long thresholdInMsToUseConcurrency; 51 52 private boolean useLegacyDiff = false; 53 54 private boolean useSvnKit = false; 55 56 /** 57 * Constructor for StatSvnTask. 58 */ StatSvnTask()59 public StatSvnTask() { 60 super(); 61 } 62 63 /** 64 * Runs the task 65 * 66 * @throws buildException 67 * if an IO Error occurs 68 */ execute()69 public void execute() { 70 try { 71 this.initProperties(); 72 73 Main.init(); 74 75 // main usually builds checks the command line here but we will skip 76 // that step as it is done in initProperties 77 78 Main.generate(); 79 } catch (final Exception e) { 80 SvnConfigurationOptions.getTaskLogger().error(Main.printStackTrace(e)); 81 } 82 } 83 84 /** 85 * method initializes the ConfigurationOptions object with received values. 86 */ initProperties()87 protected void initProperties() throws ConfigurationException { 88 super.initProperties(); 89 90 SvnConfigurationOptions.setAnonymize(this.anonymize); 91 92 if (this.cacheDirectory != null) { 93 SvnConfigurationOptions.setCacheDir(this.cacheDirectory); 94 } else { 95 SvnConfigurationOptions.setCacheDirToDefault(); 96 } 97 98 if (this.svnPassword != null) { 99 SvnConfigurationOptions.setSvnPassword(this.svnPassword); 100 } 101 if (this.svnUsername != null) { 102 SvnConfigurationOptions.setSvnUsername(this.svnUsername); 103 } 104 if (this.numberSvnDiffThreads != 0) { 105 SvnConfigurationOptions.setNumberSvnDiffThreads(this.numberSvnDiffThreads); 106 } 107 if (this.thresholdInMsToUseConcurrency != 0) { 108 SvnConfigurationOptions.setThresholdInMsToUseConcurrency(this.thresholdInMsToUseConcurrency); 109 } 110 if (this.useLegacyDiff) { // only override if we don't want it. 111 SvnConfigurationOptions.setLegacyDiff(true); 112 } 113 if (this.useSvnKit) { // only override if we don't want it. 114 SvnConfigurationOptions.setUsingSvnKit(true); 115 } 116 SvnConfigurationOptions.setTaskLogger(new AntTaskLogger(this)); 117 } 118 119 /** 120 * @param anonymize 121 * Set Stats to be anonym or not. 122 */ setAnonymize(final boolean anonymize)123 public void setAnonymize(final boolean anonymize) { 124 this.anonymize = anonymize; 125 } 126 127 /** 128 * @param cacheDirectory 129 * String representing the cache directory of the program 130 */ setCacheDir(final String cacheDir)131 public void setCacheDir(final String cacheDir) { 132 this.cacheDirectory = cacheDir; 133 } 134 135 /** 136 * @param password 137 * The svnPassword to set. 138 */ setPassword(final String password)139 public void setPassword(final String password) { 140 this.svnPassword = password; 141 } 142 143 /** 144 * @param username 145 * The svnUsername to set. 146 */ setUsername(final String username)147 public void setUsername(final String username) { 148 this.svnUsername = username; 149 } 150 151 /** 152 * @param threads 153 * the numberSvnDiffThreads to set 154 */ setThreads(final int threads)155 public void setThreads(final int threads) { 156 this.numberSvnDiffThreads = threads; 157 } 158 159 /** 160 * @param thresholdInMsToUseConcurrency 161 * the thresholdInMsToUseConcurrency to set 162 */ setConcurrencyThreshold(final long thresholdToUseConcurrency)163 public void setConcurrencyThreshold(final long thresholdToUseConcurrency) { 164 this.thresholdInMsToUseConcurrency = thresholdToUseConcurrency; 165 } 166 167 /** 168 * Should we use a one diff per-file-per-revision or should we use the newer one diff per-revision? 169 * 170 * @param isLegacy true if the legacy diff should be used. 171 */ setLegacyDiff(final boolean isLegacy)172 public void setLegacyDiff(final boolean isLegacy) { 173 this.useLegacyDiff = isLegacy; 174 } 175 176 /** 177 * Should we use svn kit to query the repository? 178 * 179 * @param isSvnKit true if we want to use svnkit. 180 */ setSvnKit(final boolean isSvnKit)181 public void setSvnKit(final boolean isSvnKit) { 182 this.useSvnKit = isSvnKit; 183 } 184 } 185