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