1 18 19 package org.apache.tools.ant.taskdefs.optional.clearcase; 20 21 import org.apache.tools.ant.BuildException; 22 import org.apache.tools.ant.Project; 23 import org.apache.tools.ant.taskdefs.Execute; 24 import org.apache.tools.ant.types.Commandline; 25 26 82 public class CCUpdate extends ClearCase { 83 private boolean mGraphical = false; 84 private boolean mOverwrite = false; 85 private boolean mRename = false; 86 private boolean mCtime = false; 87 private boolean mPtime = false; 88 private String mLog = null; 89 90 97 public void execute() throws BuildException { 98 Commandline commandLine = new Commandline(); 99 Project aProj = getProject(); 100 int result = 0; 101 102 if (getViewPath() == null) { 104 setViewPath(aProj.getBaseDir().getPath()); 105 } 106 107 commandLine.setExecutable(getClearToolCommand()); 111 commandLine.createArgument().setValue(COMMAND_UPDATE); 112 113 checkOptions(commandLine); 115 116 getProject().log(commandLine.toString(), Project.MSG_DEBUG); 118 119 if (!getFailOnErr()) { 120 getProject().log("Ignoring any errors that occur for: " 121 + getViewPathBasename(), Project.MSG_VERBOSE); 122 } 123 result = run(commandLine); 124 if (Execute.isFailure(result) && getFailOnErr()) { 125 String msg = "Failed executing: " + commandLine.toString(); 126 throw new BuildException(msg, getLocation()); 127 } 128 } 129 130 133 private void checkOptions(Commandline cmd) { 134 if (getGraphical()) { 136 cmd.createArgument().setValue(FLAG_GRAPHICAL); 138 } else { 139 if (getOverwrite()) { 140 cmd.createArgument().setValue(FLAG_OVERWRITE); 142 } else { 143 if (getRename()) { 144 cmd.createArgument().setValue(FLAG_RENAME); 146 } else { 147 cmd.createArgument().setValue(FLAG_NOVERWRITE); 149 } 150 } 151 152 if (getCurrentTime()) { 153 cmd.createArgument().setValue(FLAG_CURRENTTIME); 155 } else { 156 if (getPreserveTime()) { 157 cmd.createArgument().setValue(FLAG_PRESERVETIME); 159 } 160 } 161 162 getLogCommand(cmd); 164 } 165 166 cmd.createArgument().setValue(getViewPath()); 168 } 169 170 175 public void setGraphical(boolean graphical) { 176 mGraphical = graphical; 177 } 178 179 184 public boolean getGraphical() { 185 return mGraphical; 186 } 187 188 193 public void setOverwrite(boolean ow) { 194 mOverwrite = ow; 195 } 196 197 202 public boolean getOverwrite() { 203 return mOverwrite; 204 } 205 206 211 public void setRename(boolean ren) { 212 mRename = ren; 213 } 214 215 220 public boolean getRename() { 221 return mRename; 222 } 223 224 230 public void setCurrentTime(boolean ct) { 231 mCtime = ct; 232 } 233 234 239 public boolean getCurrentTime() { 240 return mCtime; 241 } 242 243 249 public void setPreserveTime(boolean pt) { 250 mPtime = pt; 251 } 252 253 258 public boolean getPreserveTime() { 259 return mPtime; 260 } 261 262 268 public void setLog(String log) { 269 mLog = log; 270 } 271 272 277 public String getLog() { 278 return mLog; 279 } 280 281 282 287 private void getLogCommand(Commandline cmd) { 288 if (getLog() == null) { 289 return; 290 } else { 291 296 cmd.createArgument().setValue(FLAG_LOG); 297 cmd.createArgument().setValue(getLog()); 298 } 299 } 300 301 304 public static final String FLAG_GRAPHICAL = "-graphical"; 305 308 public static final String FLAG_LOG = "-log"; 309 312 public static final String FLAG_OVERWRITE = "-overwrite"; 313 316 public static final String FLAG_NOVERWRITE = "-noverwrite"; 317 320 public static final String FLAG_RENAME = "-rename"; 321 324 public static final String FLAG_CURRENTTIME = "-ctime"; 325 328 public static final String FLAG_PRESERVETIME = "-ptime"; 329 330 } 331 332 | Popular Tags |