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 96 public class CCMklbtype extends ClearCase { 97 private String mTypeName = null; 98 private String mVOB = null; 99 private String mComment = null; 100 private String mCfile = null; 101 private boolean mReplace = false; 102 private boolean mGlobal = false; 103 private boolean mOrdinary = true; 104 private boolean mPbranch = false; 105 private boolean mShared = false; 106 107 114 public void execute() throws BuildException { 115 Commandline commandLine = new Commandline(); 116 int result = 0; 117 118 if (getTypeName() == null) { 120 throw new BuildException("Required attribute TypeName not specified"); 121 } 122 123 commandLine.setExecutable(getClearToolCommand()); 127 commandLine.createArgument().setValue(COMMAND_MKLBTYPE); 128 129 checkOptions(commandLine); 130 131 if (!getFailOnErr()) { 132 getProject().log("Ignoring any errors that occur for: " 133 + getTypeSpecifier(), Project.MSG_VERBOSE); 134 } 135 result = run(commandLine); 136 if (Execute.isFailure(result) && getFailOnErr()) { 137 String msg = "Failed executing: " + commandLine.toString(); 138 throw new BuildException(msg, getLocation()); 139 } 140 } 141 142 143 146 private void checkOptions(Commandline cmd) { 147 if (getReplace()) { 148 cmd.createArgument().setValue(FLAG_REPLACE); 150 } 151 152 if (getOrdinary()) { 153 cmd.createArgument().setValue(FLAG_ORDINARY); 155 } else { 156 if (getGlobal()) { 157 cmd.createArgument().setValue(FLAG_GLOBAL); 159 } 160 } 161 162 if (getPbranch()) { 163 cmd.createArgument().setValue(FLAG_PBRANCH); 165 } 166 167 if (getShared()) { 168 cmd.createArgument().setValue(FLAG_SHARED); 170 } 171 172 if (getComment() != null) { 173 getCommentCommand(cmd); 175 } else { 176 if (getCommentFile() != null) { 177 getCommentFileCommand(cmd); 179 } else { 180 cmd.createArgument().setValue(FLAG_NOCOMMENT); 181 } 182 } 183 184 cmd.createArgument().setValue(getTypeSpecifier()); 186 } 187 188 189 194 public void setTypeName(String tn) { 195 mTypeName = tn; 196 } 197 198 203 public String getTypeName() { 204 return mTypeName; 205 } 206 207 212 public void setVOB(String vob) { 213 mVOB = vob; 214 } 215 216 221 public String getVOB() { 222 return mVOB; 223 } 224 225 230 public void setReplace(boolean repl) { 231 mReplace = repl; 232 } 233 234 239 public boolean getReplace() { 240 return mReplace; 241 } 242 243 248 public void setGlobal(boolean glob) { 249 mGlobal = glob; 250 } 251 252 257 public boolean getGlobal() { 258 return mGlobal; 259 } 260 261 266 public void setOrdinary(boolean ordinary) { 267 mOrdinary = ordinary; 268 } 269 270 275 public boolean getOrdinary() { 276 return mOrdinary; 277 } 278 279 284 public void setPbranch(boolean pbranch) { 285 mPbranch = pbranch; 286 } 287 288 293 public boolean getPbranch() { 294 return mPbranch; 295 } 296 297 302 public void setShared(boolean shared) { 303 mShared = shared; 304 } 305 306 311 public boolean getShared() { 312 return mShared; 313 } 314 315 320 public void setComment(String comment) { 321 mComment = comment; 322 } 323 324 329 public String getComment() { 330 return mComment; 331 } 332 333 338 public void setCommentFile(String cfile) { 339 mCfile = cfile; 340 } 341 342 347 public String getCommentFile() { 348 return mCfile; 349 } 350 351 352 358 private void getCommentCommand(Commandline cmd) { 359 if (getComment() != null) { 360 365 cmd.createArgument().setValue(FLAG_COMMENT); 366 cmd.createArgument().setValue(getComment()); 367 } 368 } 369 370 376 private void getCommentFileCommand(Commandline cmd) { 377 if (getCommentFile() != null) { 378 383 cmd.createArgument().setValue(FLAG_COMMENTFILE); 384 cmd.createArgument().setValue(getCommentFile()); 385 } 386 } 387 388 394 private String getTypeSpecifier() { 395 String typenm = null; 396 397 typenm = getTypeName(); 398 if (getVOB() != null) { 399 typenm += "@" + getVOB(); 400 } 401 402 return typenm; 403 } 404 405 406 409 public static final String FLAG_REPLACE = "-replace"; 410 413 public static final String FLAG_GLOBAL = "-global"; 414 417 public static final String FLAG_ORDINARY = "-ordinary"; 418 421 public static final String FLAG_PBRANCH = "-pbranch"; 422 425 public static final String FLAG_SHARED = "-shared"; 426 429 public static final String FLAG_COMMENT = "-c"; 430 433 public static final String FLAG_COMMENTFILE = "-cfile"; 434 437 public static final String FLAG_NOCOMMENT = "-nc"; 438 439 } 440 441 | Popular Tags |