Fields Summary |
---|
private boolean | mReplace |
private boolean | mRecurse |
private String | mVersion |
private String | mTypeName |
private String | mTypeValue |
private String | mComment |
private String | mCfile |
public static final String | FLAG_REPLACE-replace flag -- replace the existing value of the attribute |
public static final String | FLAG_RECURSE-recurse flag -- process all subdirectories |
public static final String | FLAG_VERSION-version flag -- attach attribute to specified version |
public static final String | FLAG_COMMENT-c flag -- comment to attach to the element |
public static final String | FLAG_COMMENTFILE-cfile flag -- file containing a comment to attach to the file |
public static final String | FLAG_NOCOMMENT-nc flag -- no comment is specified |
Methods Summary |
---|
private void | checkOptions(org.apache.tools.ant.types.Commandline cmd)Check the command line options.
if (getReplace()) {
// -replace
cmd.createArgument().setValue(FLAG_REPLACE);
}
if (getRecurse()) {
// -recurse
cmd.createArgument().setValue(FLAG_RECURSE);
}
if (getVersion() != null) {
// -version
getVersionCommand(cmd);
}
if (getComment() != null) {
// -c
getCommentCommand(cmd);
} else {
if (getCommentFile() != null) {
// -cfile
getCommentFileCommand(cmd);
} else {
cmd.createArgument().setValue(FLAG_NOCOMMENT);
}
}
if (getTypeName() != null) {
// type
getTypeCommand(cmd);
}
if (getTypeValue() != null) {
// type value
getTypeValueCommand(cmd);
}
// viewpath
cmd.createArgument().setValue(getViewPath());
|
public void | execute()Executes the task.
Builds a command line to execute cleartool and then calls Exec's run method
to execute the command line.
Commandline commandLine = new Commandline();
Project aProj = getProject();
int result = 0;
// Check for required attributes
if (getTypeName() == null) {
throw new BuildException("Required attribute TypeName not specified");
}
if (getTypeValue() == null) {
throw new BuildException("Required attribute TypeValue not specified");
}
// Default the viewpath to basedir if it is not specified
if (getViewPath() == null) {
setViewPath(aProj.getBaseDir().getPath());
}
// build the command line from what we got. the format is
// cleartool mkattr [options...] [viewpath ...]
// as specified in the CLEARTOOL help
commandLine.setExecutable(getClearToolCommand());
commandLine.createArgument().setValue(COMMAND_MKATTR);
checkOptions(commandLine);
if (!getFailOnErr()) {
getProject().log("Ignoring any errors that occur for: "
+ getViewPathBasename(), Project.MSG_VERBOSE);
}
// For debugging
// System.out.println(commandLine.toString());
result = run(commandLine);
if (Execute.isFailure(result) && getFailOnErr()) {
String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, getLocation());
}
|
public java.lang.String | getComment()Get comment string
return mComment;
|
private void | getCommentCommand(org.apache.tools.ant.types.Commandline cmd)Get the 'comment' command
if (getComment() != null) {
/* Had to make two separate commands here because if a space is
inserted between the flag and the value, it is treated as a
Windows filename with a space and it is enclosed in double
quotes ("). This breaks clearcase.
*/
cmd.createArgument().setValue(FLAG_COMMENT);
cmd.createArgument().setValue(getComment());
}
|
public java.lang.String | getCommentFile()Get comment file
return mCfile;
|
private void | getCommentFileCommand(org.apache.tools.ant.types.Commandline cmd)Get the 'commentfile' command
if (getCommentFile() != null) {
/* Had to make two separate commands here because if a space is
inserted between the flag and the value, it is treated as a
Windows filename with a space and it is enclosed in double
quotes ("). This breaks clearcase.
*/
cmd.createArgument().setValue(FLAG_COMMENTFILE);
cmd.createArgument().setValue(getCommentFile());
}
|
public boolean | getRecurse()Get recurse flag status
return mRecurse;
|
public boolean | getReplace()Get replace flag status
return mReplace;
|
private void | getTypeCommand(org.apache.tools.ant.types.Commandline cmd)Get the attribute type-name
String typenm = getTypeName();
if (typenm != null) {
cmd.createArgument().setValue(typenm);
}
|
public java.lang.String | getTypeName()Get attribute type-name
return mTypeName;
|
public java.lang.String | getTypeValue()Get the attribute type-value
return mTypeValue;
|
private void | getTypeValueCommand(org.apache.tools.ant.types.Commandline cmd)Get the attribute type-value
String typevl = getTypeValue();
if (typevl != null) {
if (Os.isFamily("windows")) {
typevl = "\\\"" + typevl + "\\\""; // Windows quoting of the value
} else {
typevl = "\"" + typevl + "\"";
}
cmd.createArgument().setValue(typevl);
}
|
public java.lang.String | getVersion()Get version flag status
return mVersion;
|
private void | getVersionCommand(org.apache.tools.ant.types.Commandline cmd)Get the 'version' command
if (getVersion() != null) {
/* Had to make two separate commands here because if a space is
inserted between the flag and the value, it is treated as a
Windows filename with a space and it is enclosed in double
quotes ("). This breaks clearcase.
*/
cmd.createArgument().setValue(FLAG_VERSION);
cmd.createArgument().setValue(getVersion());
}
|
public void | setComment(java.lang.String comment)Set comment string
mComment = comment;
|
public void | setCommentFile(java.lang.String cfile)Set comment file
mCfile = cfile;
|
public void | setRecurse(boolean recurse)Set recurse flag
mRecurse = recurse;
|
public void | setReplace(boolean replace)Set the replace flag
mReplace = replace;
|
public void | setTypeName(java.lang.String tn)Set the attribute type-name
mTypeName = tn;
|
public void | setTypeValue(java.lang.String tv)Set the attribute type-value
mTypeValue = tv;
|
public void | setVersion(java.lang.String version)Set the version flag
mVersion = version;
|