1 18 19 package org.apache.tools.ant.taskdefs.optional.clearcase; 20 21 import java.io.File ; 22 import org.apache.tools.ant.BuildException; 23 import org.apache.tools.ant.Project; 24 import org.apache.tools.ant.Task; 25 import org.apache.tools.ant.taskdefs.ExecTask; 26 import org.apache.tools.ant.taskdefs.Execute; 27 import org.apache.tools.ant.taskdefs.LogStreamHandler; 28 import org.apache.tools.ant.types.Commandline; 29 import org.apache.tools.ant.util.FileUtils; 30 31 32 33 47 public abstract class ClearCase extends Task { 48 private String mClearToolDir = ""; 49 private String mviewPath = null; 50 private String mobjSelect = null; 51 private static int pcnt = 0; 52 private boolean mFailonerr = true; 53 58 public final void setClearToolDir(String dir) { 59 mClearToolDir = FileUtils.translatePath(dir); 60 } 61 62 67 protected final String getClearToolCommand() { 68 String toReturn = mClearToolDir; 69 if (!toReturn.equals("") && !toReturn.endsWith("/")) { 70 toReturn += "/"; 71 } 72 73 toReturn += CLEARTOOL_EXE; 74 75 return toReturn; 76 } 77 78 83 public final void setViewPath(String viewPath) { 84 mviewPath = viewPath; 85 } 86 87 92 public String getViewPath() { 93 return mviewPath; 94 } 95 96 101 public String getViewPathBasename() { 102 return (new File (mviewPath)).getName(); 103 } 104 105 110 public final void setObjSelect(String objSelect) { 111 mobjSelect = objSelect; 112 } 113 114 119 public String getObjSelect() { 120 return mobjSelect; 121 } 122 123 128 protected int run(Commandline cmd) { 129 try { 130 Project aProj = getProject(); 131 Execute exe 132 = new Execute(new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN)); 133 exe.setAntRun(aProj); 134 exe.setWorkingDirectory(aProj.getBaseDir()); 135 exe.setCommandline(cmd.getCommandline()); 136 return exe.execute(); 137 } catch (java.io.IOException e) { 138 throw new BuildException(e, getLocation()); 139 } 140 } 141 142 147 protected String runS(Commandline cmdline) { 148 String outV = "opts.cc.runS.output" + pcnt++; 149 ExecTask exe = new ExecTask(this); 150 Commandline.Argument arg = exe.createArg(); 151 152 exe.setExecutable(cmdline.getExecutable()); 153 arg.setLine(Commandline.toString(cmdline.getArguments())); 154 exe.setOutputproperty(outV); 155 exe.execute(); 156 157 return getProject().getProperty(outV); 158 } 159 165 public void setFailOnErr(boolean failonerr) { 166 mFailonerr = failonerr; 167 } 168 169 175 public boolean getFailOnErr() { 176 return mFailonerr; 177 } 178 179 182 private static final String CLEARTOOL_EXE = "cleartool"; 183 186 public static final String COMMAND_UPDATE = "update"; 187 190 public static final String COMMAND_CHECKOUT = "checkout"; 191 194 public static final String COMMAND_CHECKIN = "checkin"; 195 198 public static final String COMMAND_UNCHECKOUT = "uncheckout"; 199 202 public static final String COMMAND_LOCK = "lock"; 203 206 public static final String COMMAND_UNLOCK = "unlock"; 207 210 public static final String COMMAND_MKBL = "mkbl"; 211 214 public static final String COMMAND_MKLABEL = "mklabel"; 215 218 public static final String COMMAND_MKLBTYPE = "mklbtype"; 219 222 public static final String COMMAND_RMTYPE = "rmtype"; 223 226 public static final String COMMAND_LSCO = "lsco"; 227 230 public static final String COMMAND_MKELEM = "mkelem"; 231 234 public static final String COMMAND_MKATTR = "mkattr"; 235 238 public static final String COMMAND_MKDIR = "mkdir"; 239 240 } 241 242 | Popular Tags |