FileDocCategorySizeDatePackage
ClearCase.javaAPI DocApache Ant 1.706997Wed Dec 13 06:16:20 GMT 2006org.apache.tools.ant.taskdefs.optional.clearcase

ClearCase

public abstract class ClearCase extends org.apache.tools.ant.Task
A base class for creating tasks for executing commands on ClearCase.

The class extends the 'exec' task as it operates by executing the cleartool program supplied with ClearCase. By default the task expects the cleartool executable to be in the path, * you can override this be specifying the cleartooldir attribute.

This class provides set and get methods for the 'viewpath' and 'objselect' attribute. It also contains constants for the flags that can be passed to cleartool.

Fields Summary
private String
mClearToolDir
private String
mviewPath
private String
mobjSelect
private static int
pcnt
private boolean
mFailonerr
private static final String
CLEARTOOL_EXE
Constant for the thing to execute
public static final String
COMMAND_UPDATE
The 'Update' command
public static final String
COMMAND_CHECKOUT
The 'Checkout' command
public static final String
COMMAND_CHECKIN
The 'Checkin' command
public static final String
COMMAND_UNCHECKOUT
The 'UndoCheckout' command
public static final String
COMMAND_LOCK
The 'Lock' command
public static final String
COMMAND_UNLOCK
The 'Unlock' command
public static final String
COMMAND_MKBL
The 'Mkbl' command
public static final String
COMMAND_MKLABEL
The 'Mklabel' command
public static final String
COMMAND_MKLBTYPE
The 'Mklbtype' command
public static final String
COMMAND_RMTYPE
The 'Rmtype' command
public static final String
COMMAND_LSCO
The 'LsCheckout' command
public static final String
COMMAND_MKELEM
The 'Mkelem' command
public static final String
COMMAND_MKATTR
The 'Mkattr' command
public static final String
COMMAND_MKDIR
The 'Mkdir' command
Constructors Summary
Methods Summary
protected final java.lang.StringgetClearToolCommand()
Builds and returns the command string to execute cleartool

return
String containing path to the executable

        String toReturn = mClearToolDir;
        if (!toReturn.equals("") && !toReturn.endsWith("/")) {
            toReturn += "/";
        }

        toReturn += CLEARTOOL_EXE;

        return toReturn;
    
public booleangetFailOnErr()
Get failonerr flag status

return
boolean containing status of failonerr flag
since
ant 1.6.1

        return mFailonerr;
    
public java.lang.StringgetObjSelect()
Get the object to operate on

return
mobjSelect

        return mobjSelect;
    
public java.lang.StringgetViewPath()
Get the path to the item in a clearcase view

return
mviewPath

        return mviewPath;
    
public java.lang.StringgetViewPathBasename()
Get the basename path of the item in a clearcase view

return
basename

        return (new File(mviewPath)).getName();
    
protected intrun(org.apache.tools.ant.types.Commandline cmd)
Execute the given command are return success or failure

param
cmd command line to execute
return
the exit status of the subprocess or INVALID

        try {
            Project aProj = getProject();
            Execute exe
                = new Execute(new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN));
            exe.setAntRun(aProj);
            exe.setWorkingDirectory(aProj.getBaseDir());
            exe.setCommandline(cmd.getCommandline());
            return exe.execute();
        } catch (java.io.IOException e) {
            throw new BuildException(e, getLocation());
        }
    
protected java.lang.StringrunS(org.apache.tools.ant.types.Commandline cmdline)
Execute the given command, and return it's output

param
cmdline command line to execute
return
output of the command line

        String   outV  = "opts.cc.runS.output" + pcnt++;
        ExecTask exe   = new ExecTask(this);
        Commandline.Argument arg = exe.createArg();

        exe.setExecutable(cmdline.getExecutable());
        arg.setLine(Commandline.toString(cmdline.getArguments()));
        exe.setOutputproperty(outV);
        exe.execute();

        return getProject().getProperty(outV);
    
public final voidsetClearToolDir(java.lang.String dir)
Set the directory where the cleartool executable is located.

param
dir the directory containing the cleartool executable

                          
         
        mClearToolDir = FileUtils.translatePath(dir);
    
public voidsetFailOnErr(boolean failonerr)
If true, command will throw an exception on failure.

param
failonerr the status to set the flag to
since
ant 1.6.1

        mFailonerr = failonerr;
    
public final voidsetObjSelect(java.lang.String objSelect)
Set the object to operate on.

param
objSelect object to operate on

        mobjSelect = objSelect;
    
public final voidsetViewPath(java.lang.String viewPath)
Set the path to the item in a ClearCase view to operate on.

param
viewPath Path to the view directory or file

        mviewPath = viewPath;