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 90 public class CCMkelem extends ClearCase { 91 private String mComment = null; 92 private String mCfile = null; 93 private boolean mNwarn = false; 94 private boolean mPtime = false; 95 private boolean mNoco = false; 96 private boolean mCheckin = false; 97 private boolean mMaster = false; 98 private String mEltype = null; 99 100 107 public void execute() throws BuildException { 108 Commandline commandLine = new Commandline(); 109 Project aProj = getProject(); 110 int result = 0; 111 112 if (getViewPath() == null) { 114 setViewPath(aProj.getBaseDir().getPath()); 115 } 116 117 commandLine.setExecutable(getClearToolCommand()); 121 commandLine.createArgument().setValue(COMMAND_MKELEM); 122 123 checkOptions(commandLine); 124 125 if (!getFailOnErr()) { 126 getProject().log("Ignoring any errors that occur for: " 127 + getViewPathBasename(), Project.MSG_VERBOSE); 128 } 129 result = run(commandLine); 130 if (Execute.isFailure(result) && getFailOnErr()) { 131 String msg = "Failed executing: " + commandLine.toString(); 132 throw new BuildException(msg, getLocation()); 133 } 134 } 135 136 137 140 private void checkOptions(Commandline cmd) { 141 if (getComment() != null) { 142 getCommentCommand(cmd); 144 } else { 145 if (getCommentFile() != null) { 146 getCommentFileCommand(cmd); 148 } else { 149 cmd.createArgument().setValue(FLAG_NOCOMMENT); 150 } 151 } 152 153 if (getNoWarn()) { 154 cmd.createArgument().setValue(FLAG_NOWARN); 156 } 157 160 if (getNoCheckout() && getCheckin()) { 161 throw new BuildException("Should choose either [nocheckout | checkin]"); 162 } 163 if (getNoCheckout()) { 164 cmd.createArgument().setValue(FLAG_NOCHECKOUT); 166 } 167 if (getCheckin()) { 168 cmd.createArgument().setValue(FLAG_CHECKIN); 170 if (getPreserveTime()) { 171 cmd.createArgument().setValue(FLAG_PRESERVETIME); 173 } 174 } 175 if (getMaster()) { 176 cmd.createArgument().setValue(FLAG_MASTER); 178 } 179 if (getEltype() != null) { 180 getEltypeCommand(cmd); 182 } 183 cmd.createArgument().setValue(getViewPath()); 185 } 186 187 192 public void setComment(String comment) { 193 mComment = comment; 194 } 195 196 201 public String getComment() { 202 return mComment; 203 } 204 205 210 public void setCommentFile(String cfile) { 211 mCfile = cfile; 212 } 213 214 219 public String getCommentFile() { 220 return mCfile; 221 } 222 223 228 public void setNoWarn(boolean nwarn) { 229 mNwarn = nwarn; 230 } 231 232 237 public boolean getNoWarn() { 238 return mNwarn; 239 } 240 241 246 public void setPreserveTime(boolean ptime) { 247 mPtime = ptime; 248 } 249 250 255 public boolean getPreserveTime() { 256 return mPtime; 257 } 258 259 264 public void setNoCheckout(boolean co) { 265 mNoco = co; 266 } 267 268 273 public boolean getNoCheckout() { 274 return mNoco; 275 } 276 277 282 public void setCheckin(boolean ci) { 283 mCheckin = ci; 284 } 285 286 291 public boolean getCheckin() { 292 return mCheckin; 293 } 294 295 301 public void setMaster(boolean master) { 302 mMaster = master; 303 } 304 305 310 public boolean getMaster() { 311 return mMaster; 312 } 313 314 319 public void setEltype(String eltype) { 320 mEltype = eltype; 321 } 322 323 328 public String getEltype() { 329 return mEltype; 330 } 331 332 333 339 private void getCommentCommand(Commandline cmd) { 340 if (getComment() != null) { 341 346 cmd.createArgument().setValue(FLAG_COMMENT); 347 cmd.createArgument().setValue(getComment()); 348 } 349 } 350 351 357 private void getCommentFileCommand(Commandline cmd) { 358 if (getCommentFile() != null) { 359 364 cmd.createArgument().setValue(FLAG_COMMENTFILE); 365 cmd.createArgument().setValue(getCommentFile()); 366 } 367 } 368 369 375 private void getEltypeCommand(Commandline cmd) { 376 if (getEltype() != null) { 377 382 cmd.createArgument().setValue(FLAG_ELTYPE); 383 cmd.createArgument().setValue(getEltype()); 384 } 385 } 386 387 390 public static final String FLAG_COMMENT = "-c"; 391 394 public static final String FLAG_COMMENTFILE = "-cfile"; 395 398 public static final String FLAG_NOCOMMENT = "-nc"; 399 402 public static final String FLAG_NOWARN = "-nwarn"; 403 406 public static final String FLAG_PRESERVETIME = "-ptime"; 407 410 public static final String FLAG_NOCHECKOUT = "-nco"; 411 414 public static final String FLAG_CHECKIN = "-ci"; 415 418 public static final String FLAG_MASTER = "-master"; 419 422 public static final String FLAG_ELTYPE = "-eltype"; 423 } 424 425 | Popular Tags |