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 80 public class CCCheckin extends ClearCase { 81 private String mComment = null; 82 private String mCfile = null; 83 private boolean mNwarn = false; 84 private boolean mPtime = false; 85 private boolean mKeep = false; 86 private boolean mIdentical = true; 87 88 95 public void execute() throws BuildException { 96 Commandline commandLine = new Commandline(); 97 Project aProj = getProject(); 98 int result = 0; 99 100 if (getViewPath() == null) { 102 setViewPath(aProj.getBaseDir().getPath()); 103 } 104 105 commandLine.setExecutable(getClearToolCommand()); 109 commandLine.createArgument().setValue(COMMAND_CHECKIN); 110 111 checkOptions(commandLine); 112 113 if (!getFailOnErr()) { 114 getProject().log("Ignoring any errors that occur for: " 115 + getViewPathBasename(), Project.MSG_VERBOSE); 116 } 117 result = run(commandLine); 118 if (Execute.isFailure(result) && getFailOnErr()) { 119 String msg = "Failed executing: " + commandLine.toString(); 120 throw new BuildException(msg, getLocation()); 121 } 122 } 123 124 125 128 private void checkOptions(Commandline cmd) { 129 if (getComment() != null) { 130 getCommentCommand(cmd); 132 } else { 133 if (getCommentFile() != null) { 134 getCommentFileCommand(cmd); 136 } else { 137 cmd.createArgument().setValue(FLAG_NOCOMMENT); 138 } 139 } 140 141 if (getNoWarn()) { 142 cmd.createArgument().setValue(FLAG_NOWARN); 144 } 145 146 if (getPreserveTime()) { 147 cmd.createArgument().setValue(FLAG_PRESERVETIME); 149 } 150 151 if (getKeepCopy()) { 152 cmd.createArgument().setValue(FLAG_KEEPCOPY); 154 } 155 156 if (getIdentical()) { 157 cmd.createArgument().setValue(FLAG_IDENTICAL); 159 } 160 161 cmd.createArgument().setValue(getViewPath()); 163 } 164 165 166 171 public void setComment(String comment) { 172 mComment = comment; 173 } 174 175 180 public String getComment() { 181 return mComment; 182 } 183 184 189 public void setCommentFile(String cfile) { 190 mCfile = cfile; 191 } 192 193 198 public String getCommentFile() { 199 return mCfile; 200 } 201 202 207 public void setNoWarn(boolean nwarn) { 208 mNwarn = nwarn; 209 } 210 211 216 public boolean getNoWarn() { 217 return mNwarn; 218 } 219 220 225 public void setPreserveTime(boolean ptime) { 226 mPtime = ptime; 227 } 228 229 234 public boolean getPreserveTime() { 235 return mPtime; 236 } 237 238 243 public void setKeepCopy(boolean keep) { 244 mKeep = keep; 245 } 246 247 252 public boolean getKeepCopy() { 253 return mKeep; 254 } 255 256 262 public void setIdentical(boolean identical) { 263 mIdentical = identical; 264 } 265 266 271 public boolean getIdentical() { 272 return mIdentical; 273 } 274 275 276 282 private void getCommentCommand(Commandline cmd) { 283 if (getComment() != null) { 284 289 cmd.createArgument().setValue(FLAG_COMMENT); 290 cmd.createArgument().setValue(getComment()); 291 } 292 } 293 294 300 private void getCommentFileCommand(Commandline cmd) { 301 if (getCommentFile() != null) { 302 307 cmd.createArgument().setValue(FLAG_COMMENTFILE); 308 cmd.createArgument().setValue(getCommentFile()); 309 } 310 } 311 312 313 316 public static final String FLAG_COMMENT = "-c"; 317 320 public static final String FLAG_COMMENTFILE = "-cfile"; 321 324 public static final String FLAG_NOCOMMENT = "-nc"; 325 328 public static final String FLAG_NOWARN = "-nwarn"; 329 332 public static final String FLAG_PRESERVETIME = "-ptime"; 333 336 public static final String FLAG_KEEPCOPY = "-keep"; 337 340 public static final String FLAG_IDENTICAL = "-identical"; 341 342 } 343 344 | Popular Tags |