1 37 package net.sourceforge.cruisecontrol.bootstrappers; 38 39 import java.io.File ; 40 41 import net.sourceforge.cruisecontrol.Bootstrapper; 42 import net.sourceforge.cruisecontrol.CruiseControlException; 43 import net.sourceforge.cruisecontrol.sourcecontrols.CMSynergy; 44 import net.sourceforge.cruisecontrol.util.ManagedCommandline; 45 import net.sourceforge.cruisecontrol.util.ValidationHelper; 46 47 import org.apache.log4j.Logger; 48 49 58 public class CMSynergyBootstrapper implements Bootstrapper { 59 60 64 private String ccmExe; 65 66 70 private String projectSpec; 71 72 75 private boolean recurse = true; 76 77 81 private File sessionFile; 82 83 86 private String sessionName; 87 88 91 private static final Logger LOG = Logger.getLogger(CMSynergyBootstrapper.class); 92 93 99 public void setCcmExe(String ccmExe) { 100 this.ccmExe = ccmExe; 101 } 102 103 109 public void setProject(String projectSpec) { 110 this.projectSpec = projectSpec; 111 } 112 113 119 public void setRecurse(boolean recurse) { 120 this.recurse = recurse; 121 } 122 123 136 public void setSessionFile(String sessionFile) { 137 this.sessionFile = new File (sessionFile); 138 } 139 140 149 public void setSessionName(String sessionName) { 150 this.sessionName = sessionName; 151 } 152 153 156 public void bootstrap() { 157 158 LOG.info("Reconfiguring project \"" + projectSpec + "\"."); 159 160 ManagedCommandline cmd = CMSynergy.createCcmCommand( 162 ccmExe, sessionName, sessionFile); 163 cmd.createArgument().setValue("reconfigure"); 164 cmd.createArgument().setValue("-project"); 165 cmd.createArgument().setValue(projectSpec); 166 if (recurse) { 167 cmd.createArgument().setValue("-recurse"); 168 } 169 170 try { 171 cmd.execute(); 172 cmd.assertExitCode(0); 173 } catch (Exception e) { 174 LOG.error( 175 "Could not reconfigure the project \"" + projectSpec + "\"." , 176 e); 177 } 178 } 179 180 183 public void validate() throws CruiseControlException { 184 ValidationHelper.assertIsSet(projectSpec, "project", this.getClass()); 186 } 187 } 188 | Popular Tags |