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 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 private boolean useLegacyDiff = false;
50
51 /**
52 * Constructor for StatSvnTask.
53 */
54 public StatSvnTask() {
55 super();
56 }
57
58 /**
59 * Runs the task
60 *
61 * @throws buildException
62 * if an IO Error occurs
63 */
64 public void execute() {
65 try {
66 this.initProperties();
67
68 Main.init();
69
70
71
72
73 Main.generate();
74 } catch (final Exception e) {
75 SvnConfigurationOptions.getTaskLogger().error(Main.printStackTrace(e));
76 }
77 }
78
79 /**
80 * method initializes the ConfigurationOptions object with received values.
81 */
82 protected void initProperties() throws ConfigurationException {
83 super.initProperties();
84 if (this.cacheDirectory != null) {
85 SvnConfigurationOptions.setCacheDir(this.cacheDirectory);
86 } else {
87 SvnConfigurationOptions.setCacheDirToDefault();
88 }
89
90 if (this.svnPassword != null) {
91 SvnConfigurationOptions.setSvnPassword(this.svnPassword);
92 }
93 if (this.svnUsername != null) {
94 SvnConfigurationOptions.setSvnUsername(this.svnUsername);
95 }
96 if (this.numberSvnDiffThreads != 0) {
97 SvnConfigurationOptions.setNumberSvnDiffThreads(this.numberSvnDiffThreads);
98 }
99 if (this.thresholdInMsToUseConcurrency != 0) {
100 SvnConfigurationOptions.setThresholdInMsToUseConcurrency(this.thresholdInMsToUseConcurrency);
101 }
102 if (this.useLegacyDiff) {
103 SvnConfigurationOptions.setLegacyDiff(true);
104 }
105 SvnConfigurationOptions.setTaskLogger(new AntTaskLogger(this));
106 }
107
108 /**
109 * @param cacheDirectory
110 * String representing the cache directory of the program
111 */
112 public void setCacheDir(final String cacheDir) {
113 this.cacheDirectory = cacheDir;
114 }
115
116 /**
117 * @param password
118 * The svnPassword to set.
119 */
120 public void setPassword(final String password) {
121 this.svnPassword = password;
122 }
123
124 /**
125 * @param username
126 * The svnUsername to set.
127 */
128 public void setUsername(final String username) {
129 this.svnUsername = username;
130 }
131
132 /**
133 * @param threads
134 * the numberSvnDiffThreads to set
135 */
136 public void setThreads(final int threads) {
137 this.numberSvnDiffThreads = threads;
138 }
139
140 /**
141 * @param thresholdInMsToUseConcurrency
142 * the thresholdInMsToUseConcurrency to set
143 */
144 public void setConcurrencyThreshold(final long thresholdToUseConcurrency) {
145 this.thresholdInMsToUseConcurrency = thresholdToUseConcurrency;
146 }
147
148 /**
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 this.useLegacyDiff = isLegacy;
155 }
156 }