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 88 public class CCRmtype extends ClearCase { 89 private String mTypeKind = null; 90 private String mTypeName = null; 91 private String mVOB = null; 92 private String mComment = null; 93 private String mCfile = null; 94 private boolean mRmall = false; 95 private boolean mIgnore = false; 96 97 104 public void execute() throws BuildException { 105 Commandline commandLine = new Commandline(); 106 int result = 0; 107 108 if (getTypeKind() == null) { 110 throw new BuildException("Required attribute TypeKind not specified"); 111 } 112 if (getTypeName() == null) { 113 throw new BuildException("Required attribute TypeName not specified"); 114 } 115 116 commandLine.setExecutable(getClearToolCommand()); 120 commandLine.createArgument().setValue(COMMAND_RMTYPE); 121 122 checkOptions(commandLine); 123 124 if (!getFailOnErr()) { 125 getProject().log("Ignoring any errors that occur for: " 126 + getTypeSpecifier(), Project.MSG_VERBOSE); 127 } 128 result = run(commandLine); 129 if (Execute.isFailure(result) && getFailOnErr()) { 130 String msg = "Failed executing: " + commandLine.toString(); 131 throw new BuildException(msg, getLocation()); 132 } 133 } 134 135 136 139 private void checkOptions(Commandline cmd) { 140 if (getIgnore()) { 141 cmd.createArgument().setValue(FLAG_IGNORE); 143 } 144 if (getRmAll()) { 145 cmd.createArgument().setValue(FLAG_RMALL); 147 cmd.createArgument().setValue(FLAG_FORCE); 148 } 149 if (getComment() != null) { 150 getCommentCommand(cmd); 152 } else { 153 if (getCommentFile() != null) { 154 getCommentFileCommand(cmd); 156 } else { 157 cmd.createArgument().setValue(FLAG_NOCOMMENT); 158 } 159 } 160 161 cmd.createArgument().setValue(getTypeSpecifier()); 163 } 164 165 170 public void setIgnore(boolean ignore) { 171 mIgnore = ignore; 172 } 173 174 179 public boolean getIgnore() { 180 return mIgnore; 181 } 182 183 188 public void setRmAll(boolean rmall) { 189 mRmall = rmall; 190 } 191 192 197 public boolean getRmAll() { 198 return mRmall; 199 } 200 201 206 public void setComment(String comment) { 207 mComment = comment; 208 } 209 210 215 public String getComment() { 216 return mComment; 217 } 218 219 224 public void setCommentFile(String cfile) { 225 mCfile = cfile; 226 } 227 228 233 public String getCommentFile() { 234 return mCfile; 235 } 236 237 242 public void setTypeKind(String tk) { 243 mTypeKind = tk; 244 } 245 246 251 public String getTypeKind() { 252 return mTypeKind; 253 } 254 255 260 public void setTypeName(String tn) { 261 mTypeName = tn; 262 } 263 264 269 public String getTypeName() { 270 return mTypeName; 271 } 272 273 278 public void setVOB(String vob) { 279 mVOB = vob; 280 } 281 282 287 public String getVOB() { 288 return mVOB; 289 } 290 291 297 private String getTypeSpecifier() { 298 String tkind = getTypeKind(); 299 String tname = getTypeName(); 300 String typeSpec = null; 301 302 typeSpec = tkind + ":" + tname; 304 if (getVOB() != null) { 305 typeSpec += "@" + getVOB(); 306 } 307 return typeSpec; 308 } 309 310 316 private void getCommentCommand(Commandline cmd) { 317 if (getComment() != null) { 318 323 cmd.createArgument().setValue(FLAG_COMMENT); 324 cmd.createArgument().setValue(getComment()); 325 } 326 } 327 328 334 private void getCommentFileCommand(Commandline cmd) { 335 if (getCommentFile() != null) { 336 341 cmd.createArgument().setValue(FLAG_COMMENTFILE); 342 cmd.createArgument().setValue(getCommentFile()); 343 } 344 } 345 346 347 350 public static final String FLAG_IGNORE = "-ignore"; 351 354 public static final String FLAG_RMALL = "-rmall"; 355 358 public static final String FLAG_FORCE = "-force"; 359 362 public static final String FLAG_COMMENT = "-c"; 363 366 public static final String FLAG_COMMENTFILE = "-cfile"; 367 370 public static final String FLAG_NOCOMMENT = "-nc"; 371 372 } 373 374 | Popular Tags |