KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > cruisecontrol > bootstrappers > AccurevBootstrapper


1 /********************************************************************************
2  * CruiseControl, a Continuous Integration Toolkit
3  * Copyright (c) 2001, ThoughtWorks, Inc.
4  * 651 W Washington Ave. Suite 600
5  * Chicago, IL 60661 USA
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * + Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * + Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  *
20  * + Neither the name of ThoughtWorks, Inc., CruiseControl, nor the
21  * names of its contributors may be used to endorse or promote
22  * products derived from this software without specific prior
23  * written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
29  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  ********************************************************************************/

37 package net.sourceforge.cruisecontrol.bootstrappers;
38
39 import net.sourceforge.cruisecontrol.Bootstrapper;
40 import net.sourceforge.cruisecontrol.CruiseControlException;
41 import net.sourceforge.cruisecontrol.builders.AntBuilder;
42 import net.sourceforge.cruisecontrol.builders.Property;
43 import net.sourceforge.cruisecontrol.sourcecontrols.accurev.AccurevCommand;
44 import net.sourceforge.cruisecontrol.sourcecontrols.accurev.AccurevCommandline;
45 import net.sourceforge.cruisecontrol.sourcecontrols.accurev.Runner;
46
47 /**
48  * Simply runs "accurev update" to update the current workspace. Automatic keep and synctime are
49  * provided as options.
50  *
51  * @author <a HREF="mailto:jason_chown@scee.net">Jason Chown</a>
52  * @author <a HREF="mailto:Nicola_Orru@scee.net">Nicola Orru'</a>
53  */

54 public class AccurevBootstrapper implements Bootstrapper {
55   private boolean verbose;
56   private boolean keep;
57   private boolean synctime;
58   private String JavaDoc workspace;
59   private Runner runner;
60   private AntBuilder delegate = new AntBuilder();
61
62   /**
63    * Enables/disables verbose logging
64    *
65    * @param verbose
66    * if true, verbose logging is enabled
67    */

68   public void setVerbose(boolean verbose) {
69     this.verbose = verbose;
70   }
71   /**
72    * Enables/disables automatic keep
73    *
74    * @param keep
75    * if true, "accurev keep -m" is run on the selected workspace, to keep al modified files
76    */

77   public void setKeep(boolean keep) {
78     this.keep = keep;
79   }
80   /**
81    * Enables/disables automatic synctime
82    *
83    * @param synctime
84    * if true, "accurev synctime" is run on the selected workspace, synchronizing the
85    * server's time with the client's
86    */

87   public void setSynctime(boolean synctime) {
88     this.synctime = synctime;
89   }
90   /**
91    * Selects a workspace
92    *
93    * @param workspace
94    * the path of the workspace to work in, in the local filesystem
95    */

96   public void setWorkspace(String JavaDoc workspace) {
97     this.workspace = workspace;
98   }
99   private void runAccurev(AccurevCommandline cmd) throws CruiseControlException {
100     if (runner != null) {
101       cmd.setRunner(runner);
102     }
103     cmd.setWorkspaceLocalPath(workspace);
104     cmd.setVerbose(verbose);
105     cmd.run();
106     cmd.assertSuccess();
107   }
108   /**
109    * Runs the bootstrapper: updates the selected workspace. If required, it runs synctime and keep
110    * before updating.
111    */

112   public void bootstrap() throws CruiseControlException {
113     if (synctime) {
114       runAccurev(AccurevCommand.SYNCTIME.create());
115     }
116     if (keep) {
117       AccurevCommandline cmdKeep = AccurevCommand.KEEP.create();
118       cmdKeep.selectModified();
119       cmdKeep.setComment("CruiseControl automatic keep");
120       runAccurev(cmdKeep);
121     }
122     runAccurev(AccurevCommand.UPDATE.create());
123   }
124   public void setRunner(Runner runner) {
125     this.runner = runner;
126   }
127
128   public void validate() throws CruiseControlException {
129       delegate.validate();
130   }
131
132   /**
133    * @see net.sourceforge.cruisecontrol.builders.AntBuilder#setSaveLogDir(String)
134    */

135   public void setSaveLogDir(String JavaDoc dir) {
136       delegate.setSaveLogDir(dir);
137   }
138
139   /**
140    * @see net.sourceforge.cruisecontrol.builders.AntBuilder#setAntWorkingDir(String)
141    */

142   public void setAntWorkingDir(String JavaDoc dir) {
143       delegate.setAntWorkingDir(dir);
144   }
145
146   /**
147    * @see net.sourceforge.cruisecontrol.builders.AntBuilder#setAntScript(String)
148    */

149   public void setAntScript(String JavaDoc antScript) {
150       delegate.setAntScript(antScript);
151   }
152
153   /**
154    * @see net.sourceforge.cruisecontrol.builders.AntBuilder#setAntHome(String)
155    */

156   public void setAntHome(String JavaDoc antHome) {
157       delegate.setAntHome(antHome);
158   }
159
160   /**
161    * @see net.sourceforge.cruisecontrol.builders.AntBuilder#setTempFile(String)
162    */

163   public void setTempFile(String JavaDoc tempFileName) {
164       delegate.setTempFile(tempFileName);
165   }
166
167   /**
168    * @see net.sourceforge.cruisecontrol.builders.AntBuilder#setTarget(String)
169    */

170   public void setTarget(String JavaDoc target) {
171       delegate.setTarget(target);
172   }
173
174   /**
175    * @see net.sourceforge.cruisecontrol.builders.AntBuilder#setBuildFile(String)
176    */

177   public void setBuildFile(String JavaDoc buildFile) {
178       delegate.setBuildFile(buildFile);
179   }
180
181   /**
182    * @see net.sourceforge.cruisecontrol.builders.AntBuilder#setUseLogger(boolean)
183    */

184   public void setUseLogger(boolean useLogger) {
185       delegate.setUseLogger(useLogger);
186   }
187
188   /**
189    * @see net.sourceforge.cruisecontrol.builders.AntBuilder#createJVMArg()
190    */

191   public Object JavaDoc createJVMArg() {
192       return delegate.createJVMArg();
193   }
194
195   /**
196    * @see net.sourceforge.cruisecontrol.builders.AntBuilder#createProperty()
197    */

198   public Property createProperty() {
199       return delegate.createProperty();
200   }
201
202   /**
203    * @see net.sourceforge.cruisecontrol.builders.AntBuilder#setUseDebug(boolean)
204    */

205   public void setUseDebug(boolean debug) {
206       delegate.setUseDebug(debug);
207   }
208
209   /**
210    * @see net.sourceforge.cruisecontrol.builders.AntBuilder#setUseQuiet(boolean)
211    */

212   public void setUseQuiet(boolean quiet) {
213       delegate.setUseQuiet(quiet);
214   }
215
216   /**
217    * @see net.sourceforge.cruisecontrol.builders.AntBuilder#getLoggerClassName()
218    */

219   public String JavaDoc getLoggerClassName() {
220       return delegate.getLoggerClassName();
221   }
222
223   /**
224    * @see net.sourceforge.cruisecontrol.builders.AntBuilder#setLoggerClassName(String)
225    */

226   public void setLoggerClassName(String JavaDoc string) {
227       delegate.setLoggerClassName(string);
228   }
229
230   /**
231    * @see net.sourceforge.cruisecontrol.builders.AntBuilder#setTimeout(long)
232    */

233   public void setTimeout(long timeout) {
234       delegate.setTimeout(timeout);
235   }
236 }
237
Popular Tags