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 CCMkbl extends ClearCase { 83 private String mComment = null; 84 private String mCfile = null; 85 private String mBaselineRootName = null; 86 private boolean mNwarn = false; 87 private boolean mIdentical = true; 88 private boolean mFull = false; 89 private boolean mNlabel = false; 90 91 92 99 public void execute() throws BuildException { 100 Commandline commandLine = new Commandline(); 101 Project aProj = getProject(); 102 int result = 0; 103 104 if (getViewPath() == null) { 106 setViewPath(aProj.getBaseDir().getPath()); 107 } 108 109 commandLine.setExecutable(getClearToolCommand()); 113 commandLine.createArgument().setValue(COMMAND_MKBL); 114 115 checkOptions(commandLine); 116 117 if (!getFailOnErr()) { 118 getProject().log("Ignoring any errors that occur for: " 119 + getBaselineRootName(), Project.MSG_VERBOSE); 120 } 121 result = run(commandLine); 122 if (Execute.isFailure(result) && getFailOnErr()) { 123 String msg = "Failed executing: " + commandLine.toString(); 124 throw new BuildException(msg, getLocation()); 125 } 126 } 127 128 129 132 private void checkOptions(Commandline cmd) { 133 if (getComment() != null) { 134 getCommentCommand(cmd); 136 } else { 137 if (getCommentFile() != null) { 138 getCommentFileCommand(cmd); 140 } else { 141 cmd.createArgument().setValue(FLAG_NOCOMMENT); 142 } 143 } 144 145 if (getIdentical()) { 146 cmd.createArgument().setValue(FLAG_IDENTICAL); 148 } 149 150 if (getFull()) { 151 cmd.createArgument().setValue(FLAG_FULL); 153 } else { 154 cmd.createArgument().setValue(FLAG_INCREMENTAL); 156 } 157 158 if (getNlabel()) { 159 cmd.createArgument().setValue(FLAG_NLABEL); 161 } 162 163 cmd.createArgument().setValue(getBaselineRootName()); 165 166 } 167 168 169 174 public void setComment(String comment) { 175 mComment = comment; 176 } 177 178 183 public String getComment() { 184 return mComment; 185 } 186 187 192 public void setCommentFile(String cfile) { 193 mCfile = cfile; 194 } 195 196 201 public String getCommentFile() { 202 return mCfile; 203 } 204 205 210 public void setBaselineRootName(String baselineRootName) { 211 mBaselineRootName = baselineRootName; 212 } 213 214 219 public String getBaselineRootName() { 220 return mBaselineRootName; 221 } 222 223 230 public void setNoWarn(boolean nwarn) { 231 mNwarn = nwarn; 232 } 233 234 239 public boolean getNoWarn() { 240 return mNwarn; 241 } 242 243 248 public void setIdentical(boolean identical) { 249 mIdentical = identical; 250 } 251 252 257 public boolean getIdentical() { 258 return mIdentical; 259 } 260 261 266 public void setFull(boolean full) { 267 mFull = full; 268 } 269 270 275 public boolean getFull() { 276 return mFull; 277 } 278 279 284 public void setNlabel(boolean nlabel) { 285 mNlabel = nlabel; 286 } 287 288 293 public boolean getNlabel() { 294 return mNlabel; 295 } 296 297 298 304 private void getCommentCommand(Commandline cmd) { 305 if (getComment() != null) { 306 311 cmd.createArgument().setValue(FLAG_COMMENT); 312 cmd.createArgument().setValue(getComment()); 313 } 314 } 315 316 322 private void getCommentFileCommand(Commandline cmd) { 323 if (getCommentFile() != null) { 324 329 cmd.createArgument().setValue(FLAG_COMMENTFILE); 330 cmd.createArgument().setValue(getCommentFile()); 331 } 332 } 333 334 335 338 public static final String FLAG_COMMENT = "-c"; 339 342 public static final String FLAG_COMMENTFILE = "-cfile"; 343 346 public static final String FLAG_NOCOMMENT = "-nc"; 347 350 public static final String FLAG_IDENTICAL = "-identical"; 351 354 public static final String FLAG_INCREMENTAL = "-incremental"; 355 358 public static final String FLAG_FULL = "-full"; 359 362 public static final String FLAG_NLABEL = "-nlabel"; 363 364 365 } 366 | Popular Tags |