1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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 */
59 public StatSvnTask() {
60 super();
61 }
62
63 /**
64 * Runs the task
65 *
66 * @throws buildException
67 * if an IO Error occurs
68 */
69 public void execute() {
70 try {
71 this.initProperties();
72
73 Main.init();
74
75
76
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 */
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) {
111 SvnConfigurationOptions.setLegacyDiff(true);
112 }
113 if (this.useSvnKit) {
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 */
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 */
131 public void setCacheDir(final String cacheDir) {
132 this.cacheDirectory = cacheDir;
133 }
134
135 /**
136 * @param password
137 * The svnPassword to set.
138 */
139 public void setPassword(final String password) {
140 this.svnPassword = password;
141 }
142
143 /**
144 * @param username
145 * The svnUsername to set.
146 */
147 public void setUsername(final String username) {
148 this.svnUsername = username;
149 }
150
151 /**
152 * @param threads
153 * the numberSvnDiffThreads to set
154 */
155 public void setThreads(final int threads) {
156 this.numberSvnDiffThreads = threads;
157 }
158
159 /**
160 * @param thresholdInMsToUseConcurrency
161 * the thresholdInMsToUseConcurrency to set
162 */
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 */
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 */
181 public void setSvnKit(final boolean isSvnKit) {
182 this.useSvnKit = isSvnKit;
183 }
184 }