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 import org.apache.tools.ant.BuildException;
31
32 /**
33 * Ant task for running StatSVN.
34 *
35 * @author Andy Glover
36 * @author Richard Cyganiak
37 * @author Benoit Xhenseval
38 * @author Jason Kealey
39 */
40 public class StatSvnTask extends StatCvsTask {
41 private String cacheDirectory;
42
43 private String svnPassword;
44
45 private String svnUsername;
46
47 private int numberSvnDiffThreads;
48
49 private long thresholdInMsToUseConcurrency;
50
51 private boolean useLegacyDiff = false;
52
53 /**
54 * Constructor for StatSvnTask.
55 */
56 public StatSvnTask() {
57 super();
58 }
59
60 /**
61 * Runs the task
62 *
63 * @throws BuildException
64 * if an IO Error occurs
65 */
66 public void execute() {
67 try {
68 this.initProperties();
69
70 Main.init();
71
72
73
74
75 Main.generate();
76 } catch (final Exception e) {
77 SvnConfigurationOptions.getTaskLogger().error(Main.printStackTrace(e));
78 }
79 }
80
81 /**
82 * method initializes the ConfigurationOptions object with received values.
83 */
84 protected void initProperties() throws ConfigurationException {
85 super.initProperties();
86 if (this.cacheDirectory != null) {
87 SvnConfigurationOptions.setCacheDir(this.cacheDirectory);
88 } else {
89 SvnConfigurationOptions.setCacheDirToDefault();
90 }
91
92 if (this.svnPassword != null) {
93 SvnConfigurationOptions.setSvnPassword(this.svnPassword);
94 }
95 if (this.svnUsername != null) {
96 SvnConfigurationOptions.setSvnUsername(this.svnUsername);
97 }
98 if (this.numberSvnDiffThreads != 0) {
99 SvnConfigurationOptions.setNumberSvnDiffThreads(this.numberSvnDiffThreads);
100 }
101 if (this.thresholdInMsToUseConcurrency != 0) {
102 SvnConfigurationOptions.setThresholdInMsToUseConcurrency(this.thresholdInMsToUseConcurrency);
103 }
104 if (this.useLegacyDiff) {
105 SvnConfigurationOptions.setLegacyDiff(true);
106 }
107 SvnConfigurationOptions.setTaskLogger(new AntTaskLogger(this));
108 }
109
110 /**
111 * @param cacheDirectory
112 * String representing the cache directory of the program
113 */
114 public void setCacheDir(final String cacheDir) {
115 this.cacheDirectory = cacheDir;
116 }
117
118 /**
119 * @param password
120 * The svnPassword to set.
121 */
122 public void setPassword(final String password) {
123 this.svnPassword = password;
124 }
125
126 /**
127 * @param username
128 * The svnUsername to set.
129 */
130 public void setUsername(final String username) {
131 this.svnUsername = username;
132 }
133
134 /**
135 * @param threads
136 * the numberSvnDiffThreads to set
137 */
138 public void setThreads(final int threads) {
139 this.numberSvnDiffThreads = threads;
140 }
141
142 /**
143 * @param thresholdInMsToUseConcurrency
144 * the thresholdInMsToUseConcurrency to set
145 */
146 public void setConcurrencyThreshold(final long thresholdToUseConcurrency) {
147 this.thresholdInMsToUseConcurrency = thresholdToUseConcurrency;
148 }
149
150 /**
151 * Should we use a one diff per-file-per-revision or should we use the newer one diff per-revision?
152 *
153 * @param isLegacy true if the legacy diff should be used.
154 */
155 public void setLegacyDiff(final boolean isLegacy) {
156 this.useLegacyDiff = isLegacy;
157 }
158 }