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 84 public class CCMklabel extends ClearCase { 85 private boolean mReplace = false; 86 private boolean mRecurse = false; 87 private String mVersion = null; 88 private String mTypeName = null; 89 private String mVOB = null; 90 private String mComment = null; 91 private String mCfile = null; 92 93 100 public void execute() throws BuildException { 101 Commandline commandLine = new Commandline(); 102 Project aProj = getProject(); 103 int result = 0; 104 105 if (getTypeName() == null) { 107 throw new BuildException("Required attribute TypeName not specified"); 108 } 109 110 if (getViewPath() == null) { 112 setViewPath(aProj.getBaseDir().getPath()); 113 } 114 115 commandLine.setExecutable(getClearToolCommand()); 119 commandLine.createArgument().setValue(COMMAND_MKLABEL); 120 121 checkOptions(commandLine); 122 123 if (!getFailOnErr()) { 124 getProject().log("Ignoring any errors that occur for: " 125 + getViewPathBasename(), Project.MSG_VERBOSE); 126 } 127 result = run(commandLine); 128 if (Execute.isFailure(result) && getFailOnErr()) { 129 String msg = "Failed executing: " + commandLine.toString(); 130 throw new BuildException(msg, getLocation()); 131 } 132 } 133 134 135 138 private void checkOptions(Commandline cmd) { 139 if (getReplace()) { 140 cmd.createArgument().setValue(FLAG_REPLACE); 142 } 143 144 if (getRecurse()) { 145 cmd.createArgument().setValue(FLAG_RECURSE); 147 } 148 149 if (getVersion() != null) { 150 getVersionCommand(cmd); 152 } 153 154 if (getComment() != null) { 155 getCommentCommand(cmd); 157 } else { 158 if (getCommentFile() != null) { 159 getCommentFileCommand(cmd); 161 } else { 162 cmd.createArgument().setValue(FLAG_NOCOMMENT); 163 } 164 } 165 166 if (getTypeName() != null) { 167 getTypeCommand(cmd); 169 } 170 171 cmd.createArgument().setValue(getViewPath()); 173 } 174 175 176 181 public void setReplace(boolean replace) { 182 mReplace = replace; 183 } 184 185 190 public boolean getReplace() { 191 return mReplace; 192 } 193 194 199 public void setRecurse(boolean recurse) { 200 mRecurse = recurse; 201 } 202 203 208 public boolean getRecurse() { 209 return mRecurse; 210 } 211 212 217 public void setVersion(String version) { 218 mVersion = version; 219 } 220 221 226 public String getVersion() { 227 return mVersion; 228 } 229 230 235 public void setComment(String comment) { 236 mComment = comment; 237 } 238 239 244 public String getComment() { 245 return mComment; 246 } 247 248 253 public void setCommentFile(String cfile) { 254 mCfile = cfile; 255 } 256 257 262 public String getCommentFile() { 263 return mCfile; 264 } 265 266 271 public void setTypeName(String tn) { 272 mTypeName = tn; 273 } 274 275 280 public String getTypeName() { 281 return mTypeName; 282 } 283 284 289 public void setVOB(String vob) { 290 mVOB = vob; 291 } 292 293 298 public String getVOB() { 299 return mVOB; 300 } 301 302 303 309 private void getVersionCommand(Commandline cmd) { 310 if (getVersion() != null) { 311 316 cmd.createArgument().setValue(FLAG_VERSION); 317 cmd.createArgument().setValue(getVersion()); 318 } 319 } 320 321 327 private void getCommentCommand(Commandline cmd) { 328 if (getComment() != null) { 329 334 cmd.createArgument().setValue(FLAG_COMMENT); 335 cmd.createArgument().setValue(getComment()); 336 } 337 } 338 339 345 private void getCommentFileCommand(Commandline cmd) { 346 if (getCommentFile() != null) { 347 352 cmd.createArgument().setValue(FLAG_COMMENTFILE); 353 cmd.createArgument().setValue(getCommentFile()); 354 } 355 } 356 357 363 private void getTypeCommand(Commandline cmd) { 364 String typenm = null; 365 366 if (getTypeName() != null) { 367 typenm = getTypeName(); 368 if (getVOB() != null) { 369 typenm += "@" + getVOB(); 370 } 371 cmd.createArgument().setValue(typenm); 372 } 373 } 374 375 376 379 public static final String FLAG_REPLACE = "-replace"; 380 383 public static final String FLAG_RECURSE = "-recurse"; 384 387 public static final String FLAG_VERSION = "-version"; 388 391 public static final String FLAG_COMMENT = "-c"; 392 395 public static final String FLAG_COMMENTFILE = "-cfile"; 396 399 public static final String FLAG_NOCOMMENT = "-nc"; 400 401 } 402 403 | Popular Tags |