| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| StatSvnTask |
|
| 1.7777777777777777;1.778 |
| 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 | private String cacheDirectory; | |
| 40 | ||
| 41 | private String svnPassword; | |
| 42 | ||
| 43 | private String svnUsername; | |
| 44 | ||
| 45 | private int numberSvnDiffThreads; | |
| 46 | ||
| 47 | private long thresholdInMsToUseConcurrency; | |
| 48 | ||
| 49 | 0 | private boolean useLegacyDiff = false; |
| 50 | ||
| 51 | 0 | /** |
| 52 | * Constructor for StatSvnTask. | |
| 53 | */ | |
| 54 | public StatSvnTask() { | |
| 55 | 0 | super(); |
| 56 | 0 | } |
| 57 | 0 | |
| 58 | 0 | /** |
| 59 | * Runs the task | |
| 60 | * | |
| 61 | * @throws buildException | |
| 62 | * if an IO Error occurs | |
| 63 | */ | |
| 64 | public void execute() { | |
| 65 | try { | |
| 66 | 0 | this.initProperties(); |
| 67 | ||
| 68 | 0 | Main.init(); |
| 69 | ||
| 70 | 0 | // main usually builds checks the command line here but we will skip |
| 71 | // that step as it is done in initProperties | |
| 72 | ||
| 73 | 0 | Main.generate(); |
| 74 | 0 | } catch (final Exception e) { |
| 75 | 0 | SvnConfigurationOptions.getTaskLogger().error(Main.printStackTrace(e)); |
| 76 | 0 | } |
| 77 | 0 | } |
| 78 | 0 | |
| 79 | 0 | /** |
| 80 | * method initializes the ConfigurationOptions object with received values. | |
| 81 | */ | |
| 82 | protected void initProperties() throws ConfigurationException { | |
| 83 | 0 | super.initProperties(); |
| 84 | 0 | if (this.cacheDirectory != null) { |
| 85 | 0 | SvnConfigurationOptions.setCacheDir(this.cacheDirectory); |
| 86 | 0 | } else { |
| 87 | 0 | SvnConfigurationOptions.setCacheDirToDefault(); |
| 88 | } | |
| 89 | 0 | |
| 90 | 0 | if (this.svnPassword != null) { |
| 91 | 0 | SvnConfigurationOptions.setSvnPassword(this.svnPassword); |
| 92 | 0 | } |
| 93 | 0 | if (this.svnUsername != null) { |
| 94 | 0 | SvnConfigurationOptions.setSvnUsername(this.svnUsername); |
| 95 | 0 | } |
| 96 | 0 | if (this.numberSvnDiffThreads != 0) { |
| 97 | 0 | SvnConfigurationOptions.setNumberSvnDiffThreads(this.numberSvnDiffThreads); |
| 98 | 0 | } |
| 99 | 0 | if (this.thresholdInMsToUseConcurrency != 0) { |
| 100 | 0 | SvnConfigurationOptions.setThresholdInMsToUseConcurrency(this.thresholdInMsToUseConcurrency); |
| 101 | 0 | } |
| 102 | 0 | if (this.useLegacyDiff) { // only override if we don't want it. |
| 103 | 0 | SvnConfigurationOptions.setLegacyDiff(true); |
| 104 | 0 | } |
| 105 | 0 | SvnConfigurationOptions.setTaskLogger(new AntTaskLogger(this)); |
| 106 | 0 | } |
| 107 | 0 | |
| 108 | 0 | /** |
| 109 | * @param cacheDirectory | |
| 110 | * String representing the cache directory of the program | |
| 111 | */ | |
| 112 | public void setCacheDir(final String cacheDir) { | |
| 113 | 0 | this.cacheDirectory = cacheDir; |
| 114 | 0 | } |
| 115 | 0 | |
| 116 | 0 | /** |
| 117 | * @param password | |
| 118 | * The svnPassword to set. | |
| 119 | */ | |
| 120 | public void setPassword(final String password) { | |
| 121 | 0 | this.svnPassword = password; |
| 122 | 0 | } |
| 123 | 0 | |
| 124 | 0 | /** |
| 125 | * @param username | |
| 126 | * The svnUsername to set. | |
| 127 | */ | |
| 128 | public void setUsername(final String username) { | |
| 129 | 0 | this.svnUsername = username; |
| 130 | 0 | } |
| 131 | 0 | |
| 132 | 0 | /** |
| 133 | * @param threads | |
| 134 | * the numberSvnDiffThreads to set | |
| 135 | */ | |
| 136 | public void setThreads(final int threads) { | |
| 137 | 0 | this.numberSvnDiffThreads = threads; |
| 138 | 0 | } |
| 139 | 0 | |
| 140 | 0 | /** |
| 141 | * @param thresholdInMsToUseConcurrency | |
| 142 | * the thresholdInMsToUseConcurrency to set | |
| 143 | */ | |
| 144 | public void setConcurrencyThreshold(final long thresholdToUseConcurrency) { | |
| 145 | 0 | this.thresholdInMsToUseConcurrency = thresholdToUseConcurrency; |
| 146 | 0 | } |
| 147 | 0 | |
| 148 | 0 | /** |
| 149 | * Should we use a one diff per-file-per-revision or should we use the newer one diff per-revision? | |
| 150 | * | |
| 151 | * @param isLegacy true if the legacy diff should be used. | |
| 152 | */ | |
| 153 | public void setLegacyDiff(final boolean isLegacy) { | |
| 154 | 0 | this.useLegacyDiff = isLegacy; |
| 155 | 0 | } |
| 156 | 0 | } |