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 65 public class CCMkdir extends ClearCase { 66 private String mComment = null; 67 private String mCfile = null; 68 private boolean mNoco = false; 69 70 77 public void execute() throws BuildException { 78 Commandline commandLine = new Commandline(); 79 Project aProj = getProject(); 80 int result = 0; 81 82 if (getViewPath() == null) { 84 setViewPath(aProj.getBaseDir().getPath()); 85 } 86 87 commandLine.setExecutable(getClearToolCommand()); 91 commandLine.createArgument().setValue(COMMAND_MKDIR); 92 93 checkOptions(commandLine); 94 95 if (!getFailOnErr()) { 96 getProject().log("Ignoring any errors that occur for: " 97 + getViewPathBasename(), Project.MSG_VERBOSE); 98 } 99 result = run(commandLine); 100 if (Execute.isFailure(result) && getFailOnErr()) { 101 String msg = "Failed executing: " + commandLine.toString(); 102 throw new BuildException(msg, getLocation()); 103 } 104 } 105 106 109 private void checkOptions(Commandline cmd) { 110 if (getComment() != null) { 111 getCommentCommand(cmd); 113 } else { 114 if (getCommentFile() != null) { 115 getCommentFileCommand(cmd); 117 } else { 118 cmd.createArgument().setValue(FLAG_NOCOMMENT); 119 } 120 } 121 if (getNoCheckout()) { 122 cmd.createArgument().setValue(FLAG_NOCHECKOUT); 124 } 125 cmd.createArgument().setValue(getViewPath()); 127 } 128 129 134 public void setComment(String comment) { 135 mComment = comment; 136 } 137 138 143 public String getComment() { 144 return mComment; 145 } 146 147 152 public void setCommentFile(String cfile) { 153 mCfile = cfile; 154 } 155 156 161 public String getCommentFile() { 162 return mCfile; 163 } 164 165 170 public void setNoCheckout(boolean co) { 171 mNoco = co; 172 } 173 174 179 public boolean getNoCheckout() { 180 return mNoco; 181 } 182 183 184 190 private void getCommentCommand(Commandline cmd) { 191 if (getComment() != null) { 192 197 cmd.createArgument().setValue(FLAG_COMMENT); 198 cmd.createArgument().setValue(getComment()); 199 } 200 } 201 202 208 private void getCommentFileCommand(Commandline cmd) { 209 if (getCommentFile() != null) { 210 215 cmd.createArgument().setValue(FLAG_COMMENTFILE); 216 cmd.createArgument().setValue(getCommentFile()); 217 } 218 } 219 220 223 public static final String FLAG_COMMENT = "-c"; 224 227 public static final String FLAG_COMMENTFILE = "-cfile"; 228 231 public static final String FLAG_NOCOMMENT = "-nc"; 232 235 public static final String FLAG_NOCHECKOUT = "-nco"; 236 } 237 238 | Popular Tags |