diff options
Diffstat (limited to 'framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase')
14 files changed, 4877 insertions, 0 deletions
diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckin.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckin.java new file mode 100644 index 00000000..371d418b --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckin.java @@ -0,0 +1,343 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.tools.ant.taskdefs.optional.clearcase; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.taskdefs.Execute; +import org.apache.tools.ant.types.Commandline; + +/** + * Performs ClearCase checkin. + * + * <p> + * The following attributes are interpreted: + * <table border="1"> + * <tr> + * <th>Attribute</th> + * <th>Values</th> + * <th>Required</th> + * </tr> + * <tr> + * <td>viewpath</td> + * <td>Path to the ClearCase view file or directory that the command will operate on</td> + * <td>No</td> + * </tr> + * <tr> + * <td>comment</td> + * <td>Specify a comment. Only one of comment or cfile may be used.</td> + * <td>No</td> + * </tr> + * <tr> + * <td>commentfile</td> + * <td>Specify a file containing a comment. Only one of comment or cfile may be used.</td> + * <td>No</td> + * </tr> + * <tr> + * <td>nowarn</td> + * <td>Suppress warning messages</td> + * <td>No</td> + * </tr> + * <tr> + * <td>preservetime</td> + * <td>Preserve the modification time</td> + * <td>No</td> + * </tr> + * <tr> + * <td>keepcopy</td> + * <td>Keeps a copy of the file with a .keep extension</td> + * <td>No</td> + * </tr> + * <tr> + * <td>identical</td> + * <td>Allows the file to be checked in even if it is identical to the original</td> + * <td>No</td> + * </tr> + * <tr> + * <td>failonerr</td> + * <td>Throw an exception if the command fails. Default is true</td> + * <td>No</td> + * </tr> + * </table> + * + */ +public class CCCheckin extends ClearCase { + private String mComment = null; + private String mCfile = null; + private boolean mNwarn = false; + private boolean mPtime = false; + private boolean mKeep = false; + private boolean mIdentical = true; + + /** + * Executes the task. + * <p> + * Builds a command line to execute cleartool and then calls Exec's run method + * to execute the command line. + * @throws BuildException if the command fails and failonerr is set to true + */ + public void execute() throws BuildException { + Commandline commandLine = new Commandline(); + Project aProj = getProject(); + int result = 0; + + // 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 checkin [options...] [viewpath ...] + // as specified in the CLEARTOOL.EXE help + commandLine.setExecutable(getClearToolCommand()); + commandLine.createArgument().setValue(COMMAND_CHECKIN); + + checkOptions(commandLine); + + if (!getFailOnErr()) { + getProject().log("Ignoring any errors that occur for: " + + getViewPathBasename(), Project.MSG_VERBOSE); + } + result = run(commandLine); + if (Execute.isFailure(result) && getFailOnErr()) { + String msg = "Failed executing: " + commandLine.toString(); + throw new BuildException(msg, getLocation()); + } + } + + + /** + * Check the command line options. + */ + private void checkOptions(Commandline cmd) { + if (getComment() != null) { + // -c + getCommentCommand(cmd); + } else { + if (getCommentFile() != null) { + // -cfile + getCommentFileCommand(cmd); + } else { + cmd.createArgument().setValue(FLAG_NOCOMMENT); + } + } + + if (getNoWarn()) { + // -nwarn + cmd.createArgument().setValue(FLAG_NOWARN); + } + + if (getPreserveTime()) { + // -ptime + cmd.createArgument().setValue(FLAG_PRESERVETIME); + } + + if (getKeepCopy()) { + // -keep + cmd.createArgument().setValue(FLAG_KEEPCOPY); + } + + if (getIdentical()) { + // -identical + cmd.createArgument().setValue(FLAG_IDENTICAL); + } + + // viewpath + cmd.createArgument().setValue(getViewPath()); + } + + + /** + * Sets the comment string. + * + * @param comment the comment string + */ + public void setComment(String comment) { + mComment = comment; + } + + /** + * Get comment string + * + * @return String containing the comment + */ + public String getComment() { + return mComment; + } + + /** + * Specifies a file containing a comment. + * + * @param cfile the path to the comment file + */ + public void setCommentFile(String cfile) { + mCfile = cfile; + } + + /** + * Get comment file + * + * @return String containing the path to the comment file + */ + public String getCommentFile() { + return mCfile; + } + + /** + * If true, suppress warning messages. + * + * @param nwarn the status to set the flag to + */ + public void setNoWarn(boolean nwarn) { + mNwarn = nwarn; + } + + /** + * Get nowarn flag status + * + * @return boolean containing status of nwarn flag + */ + public boolean getNoWarn() { + return mNwarn; + } + + /** + * If true, preserve the modification time. + * + * @param ptime the status to set the flag to + */ + public void setPreserveTime(boolean ptime) { + mPtime = ptime; + } + + /** + * Get preservetime flag status + * + * @return boolean containing status of preservetime flag + */ + public boolean getPreserveTime() { + return mPtime; + } + + /** + * If true, keeps a copy of the file with a .keep extension. + * + * @param keep the status to set the flag to + */ + public void setKeepCopy(boolean keep) { + mKeep = keep; + } + + /** + * Get keepcopy flag status + * + * @return boolean containing status of keepcopy flag + */ + public boolean getKeepCopy() { + return mKeep; + } + + /** + * If true, allows the file to be checked in even + * if it is identical to the original. + * + * @param identical the status to set the flag to + */ + public void setIdentical(boolean identical) { + mIdentical = identical; + } + + /** + * Get identical flag status + * + * @return boolean containing status of identical flag + */ + public boolean getIdentical() { + return mIdentical; + } + + + /** + * Get the 'comment' command + * + * @param cmd containing the command line string with or + * without the comment flag and string appended + */ + private void getCommentCommand(Commandline cmd) { + 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()); + } + } + + /** + * Get the 'commentfile' command + * + * @param cmd containing the command line string with or + * without the commentfile flag and file appended + */ + private void getCommentFileCommand(Commandline cmd) { + 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()); + } + } + + + /** + * -c flag -- comment to attach to the file + */ + public static final String FLAG_COMMENT = "-c"; + /** + * -cfile flag -- file containing a comment to attach to the file + */ + public static final String FLAG_COMMENTFILE = "-cfile"; + /** + * -nc flag -- no comment is specified + */ + public static final String FLAG_NOCOMMENT = "-nc"; + /** + * -nwarn flag -- suppresses warning messages + */ + public static final String FLAG_NOWARN = "-nwarn"; + /** + * -ptime flag -- preserves the modification time + */ + public static final String FLAG_PRESERVETIME = "-ptime"; + /** + * -keep flag -- keeps a copy of the file with a .keep extension + */ + public static final String FLAG_KEEPCOPY = "-keep"; + /** + * -identical flag -- allows the file to be checked in even if it is identical to the original + */ + public static final String FLAG_IDENTICAL = "-identical"; + +} + diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckout.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckout.java new file mode 100644 index 00000000..0eaf09ac --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckout.java @@ -0,0 +1,516 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.tools.ant.taskdefs.optional.clearcase; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.taskdefs.Execute; +import org.apache.tools.ant.types.Commandline; + + +/** + * Performs ClearCase checkout. + * + * <p> + * The following attributes are interpreted: + * <table border="1"> + * <tr> + * <th>Attribute</th> + * <th>Values</th> + * <th>Required</th> + * </tr> + * <tr> + * <td>viewpath</td> + * <td>Path to the ClearCase view file or directory that the command will operate on</td> + * <td>No</td> + * <tr> + * <tr> + * <td>reserved</td> + * <td>Specifies whether to check out the file as reserved or not</td> + * <td>Yes</td> + * <tr> + * <tr> + * <td>out</td> + * <td>Creates a writable file under a different filename</td> + * <td>No</td> + * <tr> + * <tr> + * <td>nodata</td> + * <td>Checks out the file but does not create an editable file containing its data</td> + * <td>No</td> + * <tr> + * <tr> + * <td>branch</td> + * <td>Specify a branch to check out the file to</td> + * <td>No</td> + * <tr> + * <tr> + * <td>version</td> + * <td>Allows checkout of a version other than main latest</td> + * <td>No</td> + * <tr> + * <tr> + * <td>nowarn</td> + * <td>Suppress warning messages</td> + * <td>No</td> + * <tr> + * <tr> + * <td>comment</td> + * <td>Specify a comment. Only one of comment or cfile may be used.</td> + * <td>No</td> + * <tr> + * <tr> + * <td>commentfile</td> + * <td>Specify a file containing a comment. Only one of comment or cfile may be used.</td> + * <td>No</td> + * <tr> + * <tr> + * <td>notco</td> + * <td>Fail if it's already checked out to the current view. Set to false to ignore it.</td> + * <td>No</td> + * <tr> + * <tr> + * <td>failonerr</td> + * <td>Throw an exception if the command fails. Default is true</td> + * <td>No</td> + * <tr> + * </table> + * + */ +public class CCCheckout extends ClearCase { + private boolean mReserved = true; + private String mOut = null; + private boolean mNdata = false; + private String mBranch = null; + private boolean mVersion = false; + private boolean mNwarn = false; + private String mComment = null; + private String mCfile = null; + private boolean mNotco = true; + + /** + * Executes the task. + * <p> + * Builds a command line to execute cleartool and then calls Exec's run method + * to execute the command line. + * @throws BuildException if the command fails and failonerr is set to true + */ + public void execute() throws BuildException { + Commandline commandLine = new Commandline(); + Project aProj = getProject(); + int result = 0; + + // 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 checkout [options...] [viewpath ...] + // as specified in the CLEARTOOL.EXE help + commandLine.setExecutable(getClearToolCommand()); + commandLine.createArgument().setValue(COMMAND_CHECKOUT); + + checkOptions(commandLine); + /* + * If configured to not care about whether the element is + * already checked out to the current view. + * Then check to see if it is checked out. + */ + if (!getNotco() && lsCheckout()) { + getProject().log("Already checked out in this view: " + + getViewPathBasename(), Project.MSG_VERBOSE); + return; + } + if (!getFailOnErr()) { + getProject().log("Ignoring any errors that occur for: " + + getViewPathBasename(), Project.MSG_VERBOSE); + } + result = run(commandLine); + if (Execute.isFailure(result) && getFailOnErr()) { + String msg = "Failed executing: " + commandLine.toString(); + throw new BuildException(msg, getLocation()); + } + } + + /** + * Check to see if the element is checked out in the current view. + */ + private boolean lsCheckout() { + Commandline cmdl = new Commandline(); + String result; + + // build the command line from what we got the format is + // cleartool lsco [options...] [viewpath ...] + // as specified in the CLEARTOOL.EXE help + cmdl.setExecutable(getClearToolCommand()); + cmdl.createArgument().setValue(COMMAND_LSCO); + cmdl.createArgument().setValue("-cview"); + cmdl.createArgument().setValue("-short"); + cmdl.createArgument().setValue("-d"); + // viewpath + cmdl.createArgument().setValue(getViewPath()); + + result = runS(cmdl); + + // System.out.println( "lsCheckout: " + result ); + + return (result != null && result.length() > 0) ? true : false; + } + /** + * Check the command line options. + */ + private void checkOptions(Commandline cmd) { + // ClearCase items + if (getReserved()) { + // -reserved + cmd.createArgument().setValue(FLAG_RESERVED); + } else { + // -unreserved + cmd.createArgument().setValue(FLAG_UNRESERVED); + } + + if (getOut() != null) { + // -out + getOutCommand(cmd); + } else { + if (getNoData()) { + // -ndata + cmd.createArgument().setValue(FLAG_NODATA); + } + + } + + if (getBranch() != null) { + // -branch + getBranchCommand(cmd); + } else { + if (getVersion()) { + // -version + cmd.createArgument().setValue(FLAG_VERSION); + } + + } + + if (getNoWarn()) { + // -nwarn + cmd.createArgument().setValue(FLAG_NOWARN); + } + + if (getComment() != null) { + // -c + getCommentCommand(cmd); + } else { + if (getCommentFile() != null) { + // -cfile + getCommentFileCommand(cmd); + } else { + cmd.createArgument().setValue(FLAG_NOCOMMENT); + } + } + + // viewpath + cmd.createArgument().setValue(getViewPath()); + + // Print out info about the notco option + // System.out.println( "Notco: " + (getNotco() ? "yes" : "no") ); + } + + /** + * If true, checks out the file as reserved. + * + * @param reserved the status to set the flag to + */ + public void setReserved(boolean reserved) { + mReserved = reserved; + } + + /** + * Get reserved flag status + * + * @return boolean containing status of reserved flag + */ + public boolean getReserved() { + return mReserved; + } + + /** + * If true, checkout fails if the element is already checked out to the current view. + * + * @param notco the status to set the flag to + * @since ant 1.6.1 + */ + public void setNotco(boolean notco) { + mNotco = notco; + } + + /** + * Get notco flag status + * + * @return boolean containing status of notco flag + * @since ant 1.6.1 + */ + public boolean getNotco() { + return mNotco; + } + + + /** + * Creates a writable file under a different filename. + * + * @param outf the path to the out file + */ + public void setOut(String outf) { + mOut = outf; + } + + /** + * Get out file + * + * @return String containing the path to the out file + */ + public String getOut() { + return mOut; + } + + /** + * If true, checks out the file but does not create an + * editable file containing its data. + * + * @param ndata the status to set the flag to + */ + public void setNoData(boolean ndata) { + mNdata = ndata; + } + + /** + * Get nodata flag status + * + * @return boolean containing status of ndata flag + */ + public boolean getNoData() { + return mNdata; + } + + /** + * Specify a branch to check out the file to. + * + * @param branch the name of the branch + */ + public void setBranch(String branch) { + mBranch = branch; + } + + /** + * Get branch name + * + * @return String containing the name of the branch + */ + public String getBranch() { + return mBranch; + } + + /** + * If true, allows checkout of a version other than main latest. + * + * @param version the status to set the flag to + */ + public void setVersion(boolean version) { + mVersion = version; + } + + /** + * Get version flag status + * + * @return boolean containing status of version flag + */ + public boolean getVersion() { + return mVersion; + } + + /** + * If true, warning messages are suppressed. + * + * @param nwarn the status to set the flag to + */ + public void setNoWarn(boolean nwarn) { + mNwarn = nwarn; + } + + /** + * Get nowarn flag status + * + * @return boolean containing status of nwarn flag + */ + public boolean getNoWarn() { + return mNwarn; + } + + /** + * Sets the comment string. + * + * @param comment the comment string + */ + public void setComment(String comment) { + mComment = comment; + } + + /** + * Get comment string + * + * @return String containing the comment + */ + public String getComment() { + return mComment; + } + + /** + * Specifies a file containing a comment. + * + * @param cfile the path to the comment file + */ + public void setCommentFile(String cfile) { + mCfile = cfile; + } + + /** + * Get comment file + * + * @return String containing the path to the comment file + */ + public String getCommentFile() { + return mCfile; + } + + /** + * Get the 'out' command + * + * @param cmd containing the command line string with or + * without the out flag and path appended + */ + private void getOutCommand(Commandline cmd) { + if (getOut() != 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_OUT); + cmd.createArgument().setValue(getOut()); + } + } + + /** + * Get the 'branch' command + * + * @param cmd containing the command line string with or + without the branch flag and name appended + */ + private void getBranchCommand(Commandline cmd) { + if (getBranch() != 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_BRANCH); + cmd.createArgument().setValue(getBranch()); + } + } + + + /** + * Get the 'comment' command + * + * @param cmd containing the command line string with or + * without the comment flag and string appended + */ + private void getCommentCommand(Commandline cmd) { + 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()); + } + } + + /** + * Get the 'cfile' command + * + * @param cmd containing the command line string with or + * without the cfile flag and file appended + */ + private void getCommentFileCommand(Commandline cmd) { + 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()); + } + } + + /** + * -reserved flag -- check out the file as reserved + */ + public static final String FLAG_RESERVED = "-reserved"; + /** + * -reserved flag -- check out the file as unreserved + */ + public static final String FLAG_UNRESERVED = "-unreserved"; + /** + * -out flag -- create a writable file under a different filename + */ + public static final String FLAG_OUT = "-out"; + /** + * -ndata flag -- checks out the file but does not create an editable file containing its data + */ + public static final String FLAG_NODATA = "-ndata"; + /** + * -branch flag -- checks out the file on a specified branch + */ + public static final String FLAG_BRANCH = "-branch"; + /** + * -version flag -- allows checkout of a version that is not main latest + */ + public static final String FLAG_VERSION = "-version"; + /** + * -nwarn flag -- suppresses warning messages + */ + public static final String FLAG_NOWARN = "-nwarn"; + /** + * -c flag -- comment to attach to the file + */ + public static final String FLAG_COMMENT = "-c"; + /** + * -cfile flag -- file containing a comment to attach to the file + */ + public static final String FLAG_COMMENTFILE = "-cfile"; + /** + * -nc flag -- no comment is specified + */ + public static final String FLAG_NOCOMMENT = "-nc"; + +} + diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCLock.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCLock.java new file mode 100644 index 00000000..c273554e --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCLock.java @@ -0,0 +1,378 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.tools.ant.taskdefs.optional.clearcase; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.taskdefs.Execute; +import org.apache.tools.ant.types.Commandline; + + +/** + * TODO: + * comment field doesn't include all options yet + */ + + + +/** + * Performs a ClearCase Lock command. + * + * <p> + * The following attributes are interpreted: + * <table border="1"> + * <tr> + * <th>Attribute</th> + * <th>Values</th> + * <th>Required</th> + * </tr> + * <tr> + * <td>replace</td> + * <td>Specifies replacing an existing lock</td> + * <td>No</td> + * <tr> + * <tr> + * <td>nusers</td> + * <td>Specifies user(s) who can still modify the object/pname</td> + * <td>No</td> + * <tr> + * <tr> + * <td>obsolete</td> + * <td>Specifies that the object/pname should be marked obsolete</td> + * <td>No</td> + * <tr> + * <tr> + * <td>comment</td> + * <td>Specifies how to populate comments fields</td> + * <td>No</td> + * <tr> + * <tr> + * <td>pname</td> + * <td>Specifies the pathname to be locked.</td> + * <td>No</td> + * <tr> + * <td>objselect</td> + * <td>This variable is obsolete. Should use <i>objsel</i> instead.</td> + * <td>No</td> + * <tr> + * <tr> + * <td>objsel</td> + * <td>Specifies the object(s) to be unlocked.</td> + * <td>No</td> + * <tr> + * <tr> + * <td>failonerr</td> + * <td>Throw an exception if the command fails. Default is true</td> + * <td>No</td> + * <tr> + * </table> + * + */ +public class CCLock extends ClearCase { + private boolean mReplace = false; + private boolean mObsolete = false; + private String mComment = null; + private String mNusers = null; + private String mPname = null; + private String mObjselect = null; + + /** + * Executes the task. + * <p> + * Builds a command line to execute cleartool and then calls Exec's run method + * to execute the command line. + * @throws BuildException if the command fails and failonerr is set to true + */ + public void execute() throws BuildException { + Commandline commandLine = new Commandline(); + Project aProj = getProject(); + int result = 0; + + // 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 lock [options...] + // as specified in the CLEARTOOL.EXE help + commandLine.setExecutable(getClearToolCommand()); + commandLine.createArgument().setValue(COMMAND_LOCK); + + // Check the command line options + checkOptions(commandLine); + + // For debugging + // System.out.println(commandLine.toString()); + + if (!getFailOnErr()) { + getProject().log("Ignoring any errors that occur for: " + + getOpType(), Project.MSG_VERBOSE); + } + result = run(commandLine); + if (Execute.isFailure(result) && getFailOnErr()) { + String msg = "Failed executing: " + commandLine.toString(); + throw new BuildException(msg, getLocation()); + } + } + + /** + * Check the command line options. + */ +private void checkOptions(Commandline cmd) { + // ClearCase items + if (getReplace()) { + // -replace + cmd.createArgument().setValue(FLAG_REPLACE); + } + if (getObsolete()) { + // -obsolete + cmd.createArgument().setValue(FLAG_OBSOLETE); + } else { + getNusersCommand(cmd); + } + getCommentCommand(cmd); + + if (getObjselect() == null && getPname() == null) { + throw new BuildException("Should select either an element " + + "(pname) or an object (objselect)"); + } + getPnameCommand(cmd); + // object selector + if (getObjselect() != null) { + cmd.createArgument().setValue(getObjselect()); + } +} + + /** + * If true, replace an existing lock. + * + * @param replace the status to set the flag to + */ + public void setReplace(boolean replace) { + mReplace = replace; + } + + /** + * Get replace flag status + * + * @return boolean containing status of replace flag + */ + public boolean getReplace() { + return mReplace; + } + + /** + * If true, mark object as obsolete. + * + * @param obsolete the status to set the flag to + */ + public void setObsolete(boolean obsolete) { + mObsolete = obsolete; + } + + /** + * Get obsolete flag status + * + * @return boolean containing status of obsolete flag + */ + public boolean getObsolete() { + return mObsolete; + } + + /** + * Sets the users who may continue to + * edit the object while it is locked. + * + * @param nusers users excluded from lock + */ + public void setNusers(String nusers) { + mNusers = nusers; + } + + /** + * Get nusers list + * + * @return String containing the list of users excluded from lock + */ + public String getNusers() { + return mNusers; + } + + /** + * Sets how comments should be written + * for the event record(s) + * + * @param comment comment method to use + */ + public void setComment(String comment) { + mComment = comment; + } + + /** + * Get comment method + * + * @return String containing the desired comment method + */ + public String getComment() { + return mComment; + } + + /** + * Sets the pathname to be locked + * + * @param pname pathname to be locked + */ + public void setPname(String pname) { + mPname = pname; + } + + /** + * Get the pathname to be locked + * + * @return String containing the pathname to be locked + */ + public String getPname() { + return mPname; + } + + /** + * Sets the object(s) to be locked + * + * @param objsel objects to be locked + * @since ant 1.6.1 + */ + public void setObjSel(String objsel) { + mObjselect = objsel; + } + + /** + * Sets the object(s) to be locked + * + * @param objselect objects to be locked + */ + public void setObjselect(String objselect) { + mObjselect = objselect; + } + + /** + * Get list of objects to be locked + * + * @return String containing the objects to be locked + */ + public String getObjselect() { + return mObjselect; + } + + /** + * Get the 'nusers' command + * + * @param cmd containing the command line string with or + * without the nusers flag and value appended + */ + private void getNusersCommand(Commandline cmd) { + if (getNusers() == null) { + return; + } else { + /* 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_NUSERS); + cmd.createArgument().setValue(getNusers()); + } + } + + /** + * Get the 'comment' command + * + * @param cmd containing the command line string with or without the + * comment flag and value appended + */ + private void getCommentCommand(Commandline cmd) { + if (getComment() == null) { + return; + } else { + /* 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()); + } + } + + /** + * Get the 'pname' command + * + * @param cmd containing the command line string with or + * without the pname flag and value appended + */ + private void getPnameCommand(Commandline cmd) { + if (getPname() == null) { + return; + } else { + /* 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_PNAME); + cmd.createArgument().setValue(getPname()); + } + } + + /** + * Return which object/pname is being operated on + * + * @return String containing the object/pname being worked on + */ + private String getOpType() { + + if (getPname() != null) { + return getPname(); + } else { + return getObjselect(); + } + } + + /** + * -replace flag -- replace existing lock on object(s) + */ + public static final String FLAG_REPLACE = "-replace"; + /** + * -nusers flag -- list of users to exclude from lock + */ + public static final String FLAG_NUSERS = "-nusers"; + /** + * -obsolete flag -- mark locked object as obsolete + */ + public static final String FLAG_OBSOLETE = "-obsolete"; + /** + * -comment flag -- method to use for commenting events + */ + public static final String FLAG_COMMENT = "-comment"; + /** + * -pname flag -- pathname to lock + */ + public static final String FLAG_PNAME = "-pname"; +} + diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkattr.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkattr.java new file mode 100644 index 00000000..128ea16b --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkattr.java @@ -0,0 +1,425 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.tools.ant.taskdefs.optional.clearcase; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.taskdefs.Execute; +import org.apache.tools.ant.taskdefs.condition.Os; +import org.apache.tools.ant.types.Commandline; + +/** + * Task to perform mkattr command to ClearCase. + * <p> + * The following attributes are interpreted: + * <table border="1"> + * <tr> + * <th>Attribute</th> + * <th>Values</th> + * <th>Required</th> + * </tr> + * <tr> + * <td>viewpath</td> + * <td>Path to the ClearCase view file or directory that the command will operate on</td> + * <td>Yes</td> + * <tr> + * <tr> + * <td>replace</td> + * <td>Replace the value of the attribute if it already exists</td> + * <td>No</td> + * <tr> + * <tr> + * <td>recurse</td> + * <td>Process each subdirectory under viewpath</td> + * <td>No</td> + * <tr> + * <tr> + * <td>version</td> + * <td>Identify a specific version to attach the attribute to</td> + * <td>No</td> + * <tr> + * <tr> + * <td>typename</td> + * <td>Name of the attribute type</td> + * <td>Yes</td> + * <tr> + * <tr> + * <td>typevalue</td> + * <td>Value to attach to the attribute type</td> + * <td>Yes</td> + * <tr> + * <tr> + * <td>comment</td> + * <td>Specify a comment. Only one of comment or cfile may be used.</td> + * <td>No</td> + * <tr> + * <tr> + * <td>commentfile</td> + * <td>Specify a file containing a comment. Only one of comment or cfile may be used.</td> + * <td>No</td> + * <tr> + * <tr> + * <td>failonerr</td> + * <td>Throw an exception if the command fails. Default is true</td> + * <td>No</td> + * <tr> + * </table> + * + */ +public class CCMkattr extends ClearCase { + private boolean mReplace = false; + private boolean mRecurse = false; + private String mVersion = null; + private String mTypeName = null; + private String mTypeValue = null; + private String mComment = null; + private String mCfile = null; + + /** + * Executes the task. + * <p> + * Builds a command line to execute cleartool and then calls Exec's run method + * to execute the command line. + * @throws BuildException if the command fails and failonerr is set to true + */ + public void execute() throws BuildException { + 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()); + } + } + + + /** + * Check the command line options. + */ + private void checkOptions(Commandline cmd) { + 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()); + } + + + /** + * Set the replace flag + * + * @param replace the status to set the flag to + */ + public void setReplace(boolean replace) { + mReplace = replace; + } + + /** + * Get replace flag status + * + * @return boolean containing status of replace flag + */ + public boolean getReplace() { + return mReplace; + } + + /** + * Set recurse flag + * + * @param recurse the status to set the flag to + */ + public void setRecurse(boolean recurse) { + mRecurse = recurse; + } + + /** + * Get recurse flag status + * + * @return boolean containing status of recurse flag + */ + public boolean getRecurse() { + return mRecurse; + } + + /** + * Set the version flag + * + * @param version the status to set the flag to + */ + public void setVersion(String version) { + mVersion = version; + } + + /** + * Get version flag status + * + * @return boolean containing status of version flag + */ + public String getVersion() { + return mVersion; + } + + /** + * Set comment string + * + * @param comment the comment string + */ + public void setComment(String comment) { + mComment = comment; + } + + /** + * Get comment string + * + * @return String containing the comment + */ + public String getComment() { + return mComment; + } + + /** + * Set comment file + * + * @param cfile the path to the comment file + */ + public void setCommentFile(String cfile) { + mCfile = cfile; + } + + /** + * Get comment file + * + * @return String containing the path to the comment file + */ + public String getCommentFile() { + return mCfile; + } + + /** + * Set the attribute type-name + * + * @param tn the type name + */ + public void setTypeName(String tn) { + mTypeName = tn; + } + + /** + * Get attribute type-name + * + * @return String containing type name + */ + public String getTypeName() { + return mTypeName; + } + + /** + * Set the attribute type-value + * + * @param tv the type value + */ + public void setTypeValue(String tv) { + mTypeValue = tv; + } + + /** + * Get the attribute type-value + * + * @return String containing type value + */ + public String getTypeValue() { + return mTypeValue; + } + + + /** + * Get the 'version' command + * + * @param cmd CommandLine containing the command line string with or + * without the version flag and string appended + */ + private void getVersionCommand(Commandline cmd) { + 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()); + } + } + + /** + * Get the 'comment' command + * + * @param cmd containing the command line string with or + * without the comment flag and string appended + */ + private void getCommentCommand(Commandline cmd) { + 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()); + } + } + + /** + * Get the 'commentfile' command + * + * @param cmd containing the command line string with or + * without the commentfile flag and file appended + */ + private void getCommentFileCommand(Commandline cmd) { + 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()); + } + } + + /** + * Get the attribute type-name + * + * @param cmd containing the command line string with or + * without the type-name + */ + private void getTypeCommand(Commandline cmd) { + String typenm = getTypeName(); + + if (typenm != null) { + cmd.createArgument().setValue(typenm); + } + } + + /** + * Get the attribute type-value + * + * @param cmd containing the command line string with or + * without the type-value + */ + private void getTypeValueCommand(Commandline cmd) { + String typevl = getTypeValue(); + + if (typevl != null) { + if (Os.isFamily("windows")) { + typevl = "\\\"" + typevl + "\\\""; // Windows quoting of the value + } else { + typevl = "\"" + typevl + "\""; + } + cmd.createArgument().setValue(typevl); + } + } + + /** + * -replace flag -- replace the existing value of the attribute + */ + public static final String FLAG_REPLACE = "-replace"; + /** + * -recurse flag -- process all subdirectories + */ + public static final String FLAG_RECURSE = "-recurse"; + /** + * -version flag -- attach attribute to specified version + */ + public static final String FLAG_VERSION = "-version"; + /** + * -c flag -- comment to attach to the element + */ + public static final String FLAG_COMMENT = "-c"; + /** + * -cfile flag -- file containing a comment to attach to the file + */ + public static final String FLAG_COMMENTFILE = "-cfile"; + /** + * -nc flag -- no comment is specified + */ + public static final String FLAG_NOCOMMENT = "-nc"; +} + diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkbl.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkbl.java new file mode 100644 index 00000000..82c96005 --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkbl.java @@ -0,0 +1,365 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.tools.ant.taskdefs.optional.clearcase; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.taskdefs.Execute; +import org.apache.tools.ant.types.Commandline; + +/** + * Task to CreateBaseline command to ClearCase. + * <p> + * The following attributes are interpreted: + * <table border="1"> + * <tr> + * <th>Attribute</th> + * <th>Values</th> + * <th>Required</th> + * </tr> + * <tr> + * <td>comment</td> + * <td>Specify a comment. Only one of comment or cfile may be +used.</td> + * <td>No</td> + * </tr> + * <tr> + * <td>commentfile</td> + * <td>Specify a file containing a comment. Only one of comment or +cfile may be used.</td> + * <td>No</td> + * </tr> + * <tr> + * <td>baselinerootname</td> + * <td>Specify the name to be associated with the baseline.</td> + * <td>Yes</td> + * </tr> + * <tr> + * <td>nowarn</td> + * <td>Suppress warning messages</td> + * <td>No</td> + * <tr> + * <tr> + * <td>identical</td> + * <td>Allows the baseline to be created even if it is identical to the +previous baseline.</td> + * <td>No</td> + * </tr> + * <tr> + * <td>full</td> + * <td>Creates a full baseline.</td> + * <td>No</td> + * </tr> + * <tr> + * <td>nlabel</td> + * <td>Allows the baseline to be created without a label.</td> + * <td>No</td> + * </tr> + * <tr> + * <td>failonerr</td> + * <td>Throw an exception if the command fails. Default is true</td> + * <td>No</td> + * <tr> + * </table> + * + */ +public class CCMkbl extends ClearCase { + private String mComment = null; + private String mCfile = null; + private String mBaselineRootName = null; + private boolean mNwarn = false; + private boolean mIdentical = true; + private boolean mFull = false; + private boolean mNlabel = false; + + + /** + * Executes the task. + * <p> + * Builds a command line to execute cleartool and then calls Exec's run method + * to execute the command line. + * @throws BuildException if the command fails and failonerr is set to true + */ + public void execute() throws BuildException { + Commandline commandLine = new Commandline(); + Project aProj = getProject(); + int result = 0; + + // 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 checkin [options...] [viewpath ...] + // as specified in the CLEARTOOL.EXE help + commandLine.setExecutable(getClearToolCommand()); + commandLine.createArgument().setValue(COMMAND_MKBL); + + checkOptions(commandLine); + + if (!getFailOnErr()) { + getProject().log("Ignoring any errors that occur for: " + + getBaselineRootName(), Project.MSG_VERBOSE); + } + result = run(commandLine); + if (Execute.isFailure(result) && getFailOnErr()) { + String msg = "Failed executing: " + commandLine.toString(); + throw new BuildException(msg, getLocation()); + } + } + + + /** + * Check the command line options. + */ + private void checkOptions(Commandline cmd) { + if (getComment() != null) { + // -c + getCommentCommand(cmd); + } else { + if (getCommentFile() != null) { + // -cfile + getCommentFileCommand(cmd); + } else { + cmd.createArgument().setValue(FLAG_NOCOMMENT); + } + } + + if (getIdentical()) { + // -identical + cmd.createArgument().setValue(FLAG_IDENTICAL); + } + + if (getFull()) { + // -full + cmd.createArgument().setValue(FLAG_FULL); + } else { + // -incremental + cmd.createArgument().setValue(FLAG_INCREMENTAL); + } + + if (getNlabel()) { + // -nlabel + cmd.createArgument().setValue(FLAG_NLABEL); + } + + // baseline_root_name + cmd.createArgument().setValue(getBaselineRootName()); + + } + + + /** + * Set comment string + * + * @param comment the comment string + */ + public void setComment(String comment) { + mComment = comment; + } + + /** + * Get comment string + * + * @return String containing the comment + */ + public String getComment() { + return mComment; + } + + /** + * Set comment file + * + * @param cfile the path to the comment file + */ + public void setCommentFile(String cfile) { + mCfile = cfile; + } + + /** + * Get comment file + * + * @return String containing the path to the comment file + */ + public String getCommentFile() { + return mCfile; + } + + /** + * Set baseline_root_name + * + * @param baselineRootName the name of the baseline + */ + public void setBaselineRootName(String baselineRootName) { + mBaselineRootName = baselineRootName; + } + + /** + * Get baseline_root_name + * + * @return String containing the name of the baseline + */ + public String getBaselineRootName() { + return mBaselineRootName; + } + + /** + + /** + * Set the nowarn flag + * + * @param nwarn the status to set the flag to + */ + public void setNoWarn(boolean nwarn) { + mNwarn = nwarn; + } + + /** + * Get nowarn flag status + * + * @return boolean containing status of nwarn flag + */ + public boolean getNoWarn() { + return mNwarn; + } + + /** + * Set the identical flag + * + * @param identical the status to set the flag to + */ + public void setIdentical(boolean identical) { + mIdentical = identical; + } + + /** + * Get identical flag status + * + * @return boolean containing status of identical flag + */ + public boolean getIdentical() { + return mIdentical; + } + + /** + * Set the full flag + * + * @param full the status to set the flag to + */ + public void setFull(boolean full) { + mFull = full; + } + + /** + * Get full flag status + * + * @return boolean containing status of full flag + */ + public boolean getFull() { + return mFull; + } + + /** + * Set the nlabel flag + * + * @param nlabel the status to set the flag to + */ + public void setNlabel(boolean nlabel) { + mNlabel = nlabel; + } + + /** + * Get nlabel status + * + * @return boolean containing status of nlabel flag + */ + public boolean getNlabel() { + return mNlabel; + } + + + /** + * Get the 'comment' command + * + * @param cmd containing the command line string with or + * without the comment flag and string appended + */ + private void getCommentCommand(Commandline cmd) { + 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()); + } + } + + /** + * Get the 'commentfile' command + * + * @param cmd CommandLine containing the command line string with or + * without the commentfile flag and file appended + */ + private void getCommentFileCommand(Commandline cmd) { + 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()); + } + } + + + /** + * -c flag -- comment to attach to the file + */ + public static final String FLAG_COMMENT = "-c"; + /** + * -cfile flag -- file containing a comment to attach to the file + */ + public static final String FLAG_COMMENTFILE = "-cfile"; + /** + * -nc flag -- no comment is specified + */ + public static final String FLAG_NOCOMMENT = "-nc"; + /** + * -identical flag -- allows the file to be checked in even if it is identical to the original + */ + public static final String FLAG_IDENTICAL = "-identical"; + /** + * -incremental flag -- baseline to be created is incremental + */ + public static final String FLAG_INCREMENTAL = "-incremental"; + /** + * -full flag -- baseline to be created is full + */ + public static final String FLAG_FULL = "-full"; + /** + * -nlabel -- baseline to be created without a label + */ + public static final String FLAG_NLABEL = "-nlabel"; + + +} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkdir.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkdir.java new file mode 100644 index 00000000..4c89539f --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkdir.java @@ -0,0 +1,237 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.tools.ant.taskdefs.optional.clearcase; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.taskdefs.Execute; +import org.apache.tools.ant.types.Commandline; + +/** + * Performs ClearCase mkdir. + * + * <p> + * The following attributes are interpreted: + * <table border="1"> + * <tr> + * <th>Attribute</th> + * <th>Values</th> + * <th>Required</th> + * </tr> + * <tr> + * <td>viewpath</td> + * <td>Path to the ClearCase view directory that the command will operate on</td> + * <td>Yes</td> + * <tr> + * <tr> + * <td>comment</td> + * <td>Specify a comment. Only one of comment or cfile may be used.</td> + * <td>No</td> + * <tr> + * <tr> + * <td>commentfile</td> + * <td>Specify a file containing a comment. Only one of comment or cfile may be used.</td> + * <td>No</td> + * <tr> + * <tr> + * <td>nocheckout</td> + * <td>Do not checkout after element creation</td> + * <td>No</td> + * <tr> + * <tr> + * <td>failonerr</td> + * <td>Throw an exception if the command fails. Default is true</td> + * <td>No</td> + * <tr> + * </table> + * + */ +public class CCMkdir extends ClearCase { + private String mComment = null; + private String mCfile = null; + private boolean mNoco = false; + + /** + * Executes the task. + * <p> + * Builds a command line to execute cleartool and then calls Exec's run method + * to execute the command line. + * @throws BuildException if the command fails and failonerr is set to true + */ + public void execute() throws BuildException { + Commandline commandLine = new Commandline(); + Project aProj = getProject(); + int result = 0; + + // 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 mkelem [options...] [viewpath ...] + // as specified in the CLEARTOOL.EXE help + commandLine.setExecutable(getClearToolCommand()); + commandLine.createArgument().setValue(COMMAND_MKDIR); + + checkOptions(commandLine); + + if (!getFailOnErr()) { + getProject().log("Ignoring any errors that occur for: " + + getViewPathBasename(), Project.MSG_VERBOSE); + } + result = run(commandLine); + if (Execute.isFailure(result) && getFailOnErr()) { + String msg = "Failed executing: " + commandLine.toString(); + throw new BuildException(msg, getLocation()); + } + } + + /** + * Check the command line options. + */ + private void checkOptions(Commandline cmd) { + if (getComment() != null) { + // -c + getCommentCommand(cmd); + } else { + if (getCommentFile() != null) { + // -cfile + getCommentFileCommand(cmd); + } else { + cmd.createArgument().setValue(FLAG_NOCOMMENT); + } + } + if (getNoCheckout()) { + // -nco + cmd.createArgument().setValue(FLAG_NOCHECKOUT); + } + // viewpath + cmd.createArgument().setValue(getViewPath()); + } + + /** + * Sets the comment string. + * + * @param comment the comment string + */ + public void setComment(String comment) { + mComment = comment; + } + + /** + * Get comment string + * + * @return String containing the comment + */ + public String getComment() { + return mComment; + } + + /** + * Specifies a file containing a comment. + * + * @param cfile the path to the comment file + */ + public void setCommentFile(String cfile) { + mCfile = cfile; + } + + /** + * Get comment file + * + * @return String containing the path to the comment file + */ + public String getCommentFile() { + return mCfile; + } + + /** + * If true, do not checkout element after creation. + * + * @param co the status to set the flag to + */ + public void setNoCheckout(boolean co) { + mNoco = co; + } + + /** + * Get no checkout flag status + * + * @return boolean containing status of noco flag + */ + public boolean getNoCheckout() { + return mNoco; + } + + + /** + * Get the 'comment' command + * + * @param cmd containing the command line string with or + * without the comment flag and string appended + */ + private void getCommentCommand(Commandline cmd) { + 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()); + } + } + + /** + * Get the 'commentfile' command + * + * @param cmd containing the command line string with or + * without the commentfile flag and file appended + */ + private void getCommentFileCommand(Commandline cmd) { + 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()); + } + } + + /** + * -c flag -- comment to attach to the directory + */ + public static final String FLAG_COMMENT = "-c"; + /** + * -cfile flag -- file containing a comment to attach to the directory + */ + public static final String FLAG_COMMENTFILE = "-cfile"; + /** + * -nc flag -- no comment is specified + */ + public static final String FLAG_NOCOMMENT = "-nc"; + /** + * -nco flag -- do not checkout element after creation + */ + public static final String FLAG_NOCHECKOUT = "-nco"; +} + diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkelem.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkelem.java new file mode 100644 index 00000000..94faa5a6 --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkelem.java @@ -0,0 +1,424 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.tools.ant.taskdefs.optional.clearcase; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.taskdefs.Execute; +import org.apache.tools.ant.types.Commandline; + +/** + * Performs ClearCase mkelem. + * + * <p> + * The following attributes are interpreted: + * <table border="1"> + * <tr> + * <th>Attribute</th> + * <th>Values</th> + * <th>Required</th> + * </tr> + * <tr> + * <td>viewpath</td> + * <td>Path to the ClearCase view file or directory that the command will operate on</td> + * <td>Yes</td> + * <tr> + * <tr> + * <td>comment</td> + * <td>Specify a comment. Only one of comment or cfile may be used.</td> + * <td>No</td> + * <tr> + * <tr> + * <td>commentfile</td> + * <td>Specify a file containing a comment. Only one of comment or cfile may be used.</td> + * <td>No</td> + * <tr> + * <tr> + * <td>nowarn</td> + * <td>Suppress warning messages</td> + * <td>No</td> + * <tr> + * <tr> + * <td>nocheckout</td> + * <td>Do not checkout after element creation</td> + * <td>No</td> + * <tr> + * <tr> + * <td>checkin</td> + * <td>Checkin element after creation</td> + * <td>No</td> + * <tr> + * <tr> + * <td>preservetime</td> + * <td>Preserve the modification time (for checkin)</td> + * <td>No</td> + * <tr> + * <tr> + * <td>master</td> + * <td>Assign mastership of the main branch to the current site</td> + * <td>No</td> + * <tr> + * <tr> + * <td>eltype</td> + * <td>Element type to use during element creation</td> + * <td>No</td> + * <tr> + * <tr> + * <td>failonerr</td> + * <td>Throw an exception if the command fails. Default is true</td> + * <td>No</td> + * <tr> + * </table> + * + */ +public class CCMkelem extends ClearCase { + private String mComment = null; + private String mCfile = null; + private boolean mNwarn = false; + private boolean mPtime = false; + private boolean mNoco = false; + private boolean mCheckin = false; + private boolean mMaster = false; + private String mEltype = null; + + /** + * Executes the task. + * <p> + * Builds a command line to execute cleartool and then calls Exec's run method + * to execute the command line. + * @throws BuildException if the command fails and failonerr is set to true + */ + public void execute() throws BuildException { + Commandline commandLine = new Commandline(); + Project aProj = getProject(); + int result = 0; + + // 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 mkelem [options...] [viewpath ...] + // as specified in the CLEARTOOL.EXE help + commandLine.setExecutable(getClearToolCommand()); + commandLine.createArgument().setValue(COMMAND_MKELEM); + + checkOptions(commandLine); + + if (!getFailOnErr()) { + getProject().log("Ignoring any errors that occur for: " + + getViewPathBasename(), Project.MSG_VERBOSE); + } + result = run(commandLine); + if (Execute.isFailure(result) && getFailOnErr()) { + String msg = "Failed executing: " + commandLine.toString(); + throw new BuildException(msg, getLocation()); + } + } + + + /** + * Check the command line options. + */ + private void checkOptions(Commandline cmd) { + if (getComment() != null) { + // -c + getCommentCommand(cmd); + } else { + if (getCommentFile() != null) { + // -cfile + getCommentFileCommand(cmd); + } else { + cmd.createArgument().setValue(FLAG_NOCOMMENT); + } + } + + if (getNoWarn()) { + // -nwarn + cmd.createArgument().setValue(FLAG_NOWARN); + } + /* + * Should choose either -ci or -nco. + */ + if (getNoCheckout() && getCheckin()) { + throw new BuildException("Should choose either [nocheckout | checkin]"); + } + if (getNoCheckout()) { + // -nco + cmd.createArgument().setValue(FLAG_NOCHECKOUT); + } + if (getCheckin()) { + // -ci + cmd.createArgument().setValue(FLAG_CHECKIN); + if (getPreserveTime()) { + // -ptime + cmd.createArgument().setValue(FLAG_PRESERVETIME); + } + } + if (getMaster()) { + // -master + cmd.createArgument().setValue(FLAG_MASTER); + } + if (getEltype() != null) { + // -eltype + getEltypeCommand(cmd); + } + // viewpath + cmd.createArgument().setValue(getViewPath()); + } + + /** + * Sets the comment string. + * + * @param comment the comment string + */ + public void setComment(String comment) { + mComment = comment; + } + + /** + * Get comment string + * + * @return String containing the comment + */ + public String getComment() { + return mComment; + } + + /** + * Specifies a file containing a comment. + * + * @param cfile the path to the comment file + */ + public void setCommentFile(String cfile) { + mCfile = cfile; + } + + /** + * Get comment file + * + * @return String containing the path to the comment file + */ + public String getCommentFile() { + return mCfile; + } + + /** + * If true, suppress warning messages. + * + * @param nwarn the status to set the flag to + */ + public void setNoWarn(boolean nwarn) { + mNwarn = nwarn; + } + + /** + * Get nowarn flag status + * + * @return boolean containing status of nwarn flag + */ + public boolean getNoWarn() { + return mNwarn; + } + + /** + * If true, preserve the modification time. + * + * @param ptime the status to set the flag to + */ + public void setPreserveTime(boolean ptime) { + mPtime = ptime; + } + + /** + * Get preservetime flag status + * + * @return boolean containing status of preservetime flag + */ + public boolean getPreserveTime() { + return mPtime; + } + + /** + * If true, do not checkout element after creation. + * + * @param co the status to set the flag to + */ + public void setNoCheckout(boolean co) { + mNoco = co; + } + + /** + * Get no checkout flag status + * + * @return boolean containing status of noco flag + */ + public boolean getNoCheckout() { + return mNoco; + } + + /** + * If true, checkin the element after creation + * + * @param ci the status to set the flag to + */ + public void setCheckin(boolean ci) { + mCheckin = ci; + } + + /** + * Get ci flag status + * + * @return boolean containing status of ci flag + */ + public boolean getCheckin() { + return mCheckin; + } + + /** + * If true, changes mastership of the main branch + * to the current site + * + * @param master the status to set the flag to + */ + public void setMaster(boolean master) { + mMaster = master; + } + + /** + * Get master flag status + * + * @return boolean containing status of master flag + */ + public boolean getMaster() { + return mMaster; + } + + /** + * Specifies the element type to use. + * + * @param eltype to create element + */ + public void setEltype(String eltype) { + mEltype = eltype; + } + + /** + * Get element type + * + * @return String containing the element type + */ + public String getEltype() { + return mEltype; + } + + + /** + * Get the 'comment' command + * + * @param cmd containing the command line string with or + * without the comment flag and string appended + */ + private void getCommentCommand(Commandline cmd) { + 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()); + } + } + + /** + * Get the 'commentfile' command + * + * @param cmd containing the command line string with or + * without the commentfile flag and file appended + */ + private void getCommentFileCommand(Commandline cmd) { + 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()); + } + } + + /** + * Get the 'element type' command + * + * @param cmd containing the command line string with or + * without the comment flag and string appended + */ + private void getEltypeCommand(Commandline cmd) { + if (getEltype() != 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_ELTYPE); + cmd.createArgument().setValue(getEltype()); + } + } + + /** + * -c flag -- comment to attach to the file + */ + public static final String FLAG_COMMENT = "-c"; + /** + * -cfile flag -- file containing a comment to attach to the file + */ + public static final String FLAG_COMMENTFILE = "-cfile"; + /** + * -nc flag -- no comment is specified + */ + public static final String FLAG_NOCOMMENT = "-nc"; + /** + * -nwarn flag -- suppresses warning messages + */ + public static final String FLAG_NOWARN = "-nwarn"; + /** + * -ptime flag -- preserves the modification time on checkin + */ + public static final String FLAG_PRESERVETIME = "-ptime"; + /** + * -nco flag -- do not checkout element after creation + */ + public static final String FLAG_NOCHECKOUT = "-nco"; + /** + * -ci flag -- checkin element after creation + */ + public static final String FLAG_CHECKIN = "-ci"; + /** + * -master flag -- change mastership of main branch to current site + */ + public static final String FLAG_MASTER = "-master"; + /** + * -eltype flag -- element type to use during creation + */ + public static final String FLAG_ELTYPE = "-eltype"; +} + diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMklabel.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMklabel.java new file mode 100644 index 00000000..e3d288df --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMklabel.java @@ -0,0 +1,402 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.tools.ant.taskdefs.optional.clearcase; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.taskdefs.Execute; +import org.apache.tools.ant.types.Commandline; + +/** + * Task to perform mklabel command to ClearCase. + * <p> + * The following attributes are interpreted: + * <table border="1"> + * <tr> + * <th>Attribute</th> + * <th>Values</th> + * <th>Required</th> + * </tr> + * <tr> + * <td>viewpath</td> + * <td>Path to the ClearCase view file or directory that the command will operate on</td> + * <td>No</td> + * <tr> + * <tr> + * <td>replace</td> + * <td>Replace a label of the same type on the same branch</td> + * <td>No</td> + * <tr> + * <tr> + * <td>recurse</td> + * <td>Process each subdirectory under viewpath</td> + * <td>No</td> + * <tr> + * <tr> + * <td>version</td> + * <td>Identify a specific version to attach the label to</td> + * <td>No</td> + * <tr> + * <tr> + * <td>typename</td> + * <td>Name of the label type</td> + * <td>Yes</td> + * <tr> + * <tr> + * <td>vob</td> + * <td>Name of the VOB</td> + * <td>No</td> + * <tr> + * <tr> + * <td>comment</td> + * <td>Specify a comment. Only one of comment or cfile may be used.</td> + * <td>No</td> + * <tr> + * <tr> + * <td>commentfile</td> + * <td>Specify a file containing a comment. Only one of comment or cfile may be used.</td> + * <td>No</td> + * <tr> + * <tr> + * <td>failonerr</td> + * <td>Throw an exception if the command fails. Default is true</td> + * <td>No</td> + * <tr> + * </table> + * + */ +public class CCMklabel extends ClearCase { + private boolean mReplace = false; + private boolean mRecurse = false; + private String mVersion = null; + private String mTypeName = null; + private String mVOB = null; + private String mComment = null; + private String mCfile = null; + + /** + * Executes the task. + * <p> + * Builds a command line to execute cleartool and then calls Exec's run method + * to execute the command line. + * @throws BuildException if the command fails and failonerr is set to true + */ + public void execute() throws BuildException { + 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"); + } + + // 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 mklabel [options...] [viewpath ...] + // as specified in the CLEARTOOL help + commandLine.setExecutable(getClearToolCommand()); + commandLine.createArgument().setValue(COMMAND_MKLABEL); + + checkOptions(commandLine); + + if (!getFailOnErr()) { + getProject().log("Ignoring any errors that occur for: " + + getViewPathBasename(), Project.MSG_VERBOSE); + } + result = run(commandLine); + if (Execute.isFailure(result) && getFailOnErr()) { + String msg = "Failed executing: " + commandLine.toString(); + throw new BuildException(msg, getLocation()); + } + } + + + /** + * Check the command line options. + */ + private void checkOptions(Commandline cmd) { + 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); + } + + // viewpath + cmd.createArgument().setValue(getViewPath()); + } + + + /** + * Set the replace flag + * + * @param replace the status to set the flag to + */ + public void setReplace(boolean replace) { + mReplace = replace; + } + + /** + * Get replace flag status + * + * @return boolean containing status of replace flag + */ + public boolean getReplace() { + return mReplace; + } + + /** + * Set recurse flag + * + * @param recurse the status to set the flag to + */ + public void setRecurse(boolean recurse) { + mRecurse = recurse; + } + + /** + * Get recurse flag status + * + * @return boolean containing status of recurse flag + */ + public boolean getRecurse() { + return mRecurse; + } + + /** + * Set the version flag + * + * @param version the status to set the flag to + */ + public void setVersion(String version) { + mVersion = version; + } + + /** + * Get version flag status + * + * @return boolean containing status of version flag + */ + public String getVersion() { + return mVersion; + } + + /** + * Set comment string + * + * @param comment the comment string + */ + public void setComment(String comment) { + mComment = comment; + } + + /** + * Get comment string + * + * @return String containing the comment + */ + public String getComment() { + return mComment; + } + + /** + * Set comment file + * + * @param cfile the path to the comment file + */ + public void setCommentFile(String cfile) { + mCfile = cfile; + } + + /** + * Get comment file + * + * @return String containing the path to the comment file + */ + public String getCommentFile() { + return mCfile; + } + + /** + * Set the type-name + * + * @param tn the type name + */ + public void setTypeName(String tn) { + mTypeName = tn; + } + + /** + * Get type-name + * + * @return String containing type name + */ + public String getTypeName() { + return mTypeName; + } + + /** + * Set the VOB name + * + * @param vob the VOB name + */ + public void setVOB(String vob) { + mVOB = vob; + } + + /** + * Get VOB name + * + * @return String containing VOB name + */ + public String getVOB() { + return mVOB; + } + + + /** + * Get the 'version' command + * + * @param cmd CommandLine containing the command line string with or + * without the version flag and string appended + */ + private void getVersionCommand(Commandline cmd) { + 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()); + } + } + + /** + * Get the 'comment' command + * + * @param cmd containing the command line string with or + * without the comment flag and string appended + */ + private void getCommentCommand(Commandline cmd) { + 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()); + } + } + + /** + * Get the 'commentfile' command + * + * @param cmd containing the command line string with or + * without the commentfile flag and file appended + */ + private void getCommentFileCommand(Commandline cmd) { + 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()); + } + } + + /** + * Get the type-name + * + * @param cmd containing the command line string with or + * without the type-name + */ + private void getTypeCommand(Commandline cmd) { + String typenm = null; + + if (getTypeName() != null) { + typenm = getTypeName(); + if (getVOB() != null) { + typenm += "@" + getVOB(); + } + cmd.createArgument().setValue(typenm); + } + } + + + /** + * -replace flag -- replace another label of the same type + */ + public static final String FLAG_REPLACE = "-replace"; + /** + * -recurse flag -- process all subdirectories + */ + public static final String FLAG_RECURSE = "-recurse"; + /** + * -version flag -- attach label to specified version + */ + public static final String FLAG_VERSION = "-version"; + /** + * -c flag -- comment to attach to the file + */ + public static final String FLAG_COMMENT = "-c"; + /** + * -cfile flag -- file containing a comment to attach to the file + */ + public static final String FLAG_COMMENTFILE = "-cfile"; + /** + * -nc flag -- no comment is specified + */ + public static final String FLAG_NOCOMMENT = "-nc"; + +} + diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMklbtype.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMklbtype.java new file mode 100644 index 00000000..7bb7192e --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMklbtype.java @@ -0,0 +1,440 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.tools.ant.taskdefs.optional.clearcase; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.taskdefs.Execute; +import org.apache.tools.ant.types.Commandline; + +/** + * Task to perform mklbtype command to ClearCase. + * <p> + * The following attributes are interpreted: + * <table border="1"> + * <tr> + * <th>Attribute</th> + * <th>Values</th> + * <th>Required</th> + * </tr> + * <tr> + * <td>typename</td> + * <td>Name of the label type to create</td> + * <td>Yes</td> + * <tr> + * <tr> + * <td>vob</td> + * <td>Name of the VOB</td> + * <td>No</td> + * <tr> + * <tr> + * <td>replace</td> + * <td>Replace an existing label definition of the same type</td> + * <td>No</td> + * <tr> + * <tr> + * <td>global</td> + * <td>Either global or ordinary can be specified, not both. + * Creates a label type that is global to the VOB or to + * VOBs that use this VOB</td> + * <td>No</td> + * <tr> + * <tr> + * <td>ordinary</td> + * <td>Either global or ordinary can be specified, not both. + * Creates a label type that can be used only in the current + * VOB. <B>Default</B></td> + * <td>No</td> + * <tr> + * <tr> + * <td>pbranch</td> + * <td>Allows the label type to be used once per branch in a given + * element's version tree</td> + * <td>No</td> + * <tr> + * <tr> + * <td>shared</td> + * <td>Sets the way mastership is checked by ClearCase. See ClearCase + * documentation for details</td> + * <td>No</td> + * <tr> + * <tr> + * <td>comment</td> + * <td>Specify a comment. Only one of comment or cfile may be used.</td> + * <td>No</td> + * <tr> + * <tr> + * <td>commentfile</td> + * <td>Specify a file containing a comment. Only one of comment or + * cfile may be used.</td> + * <td>No</td> + * <tr> + * <tr> + * <td>failonerr</td> + * <td>Throw an exception if the command fails. Default is true</td> + * <td>No</td> + * <tr> + * </table> + * + */ +public class CCMklbtype extends ClearCase { + private String mTypeName = null; + private String mVOB = null; + private String mComment = null; + private String mCfile = null; + private boolean mReplace = false; + private boolean mGlobal = false; + private boolean mOrdinary = true; + private boolean mPbranch = false; + private boolean mShared = false; + + /** + * Executes the task. + * <p> + * Builds a command line to execute cleartool and then calls Exec's run method + * to execute the command line. + * @throws BuildException if the command fails and failonerr is set to true + */ + public void execute() throws BuildException { + Commandline commandLine = new Commandline(); + int result = 0; + + // Check for required attributes + if (getTypeName() == null) { + throw new BuildException("Required attribute TypeName not specified"); + } + + // build the command line from what we got. the format is + // cleartool mklbtype [options...] type-selector... + // as specified in the CLEARTOOL help + commandLine.setExecutable(getClearToolCommand()); + commandLine.createArgument().setValue(COMMAND_MKLBTYPE); + + checkOptions(commandLine); + + if (!getFailOnErr()) { + getProject().log("Ignoring any errors that occur for: " + + getTypeSpecifier(), Project.MSG_VERBOSE); + } + result = run(commandLine); + if (Execute.isFailure(result) && getFailOnErr()) { + String msg = "Failed executing: " + commandLine.toString(); + throw new BuildException(msg, getLocation()); + } + } + + + /** + * Check the command line options. + */ + private void checkOptions(Commandline cmd) { + if (getReplace()) { + // -replace + cmd.createArgument().setValue(FLAG_REPLACE); + } + + if (getOrdinary()) { + // -ordinary + cmd.createArgument().setValue(FLAG_ORDINARY); + } else { + if (getGlobal()) { + // -global + cmd.createArgument().setValue(FLAG_GLOBAL); + } + } + + if (getPbranch()) { + // -pbranch + cmd.createArgument().setValue(FLAG_PBRANCH); + } + + if (getShared()) { + // -shared + cmd.createArgument().setValue(FLAG_SHARED); + } + + if (getComment() != null) { + // -c + getCommentCommand(cmd); + } else { + if (getCommentFile() != null) { + // -cfile + getCommentFileCommand(cmd); + } else { + cmd.createArgument().setValue(FLAG_NOCOMMENT); + } + } + + // type-name@vob + cmd.createArgument().setValue(getTypeSpecifier()); + } + + + /** + * Set type-name string + * + * @param tn the type-name string + */ + public void setTypeName(String tn) { + mTypeName = tn; + } + + /** + * Get type-name string + * + * @return String containing the type-name + */ + public String getTypeName() { + return mTypeName; + } + + /** + * Set the VOB name + * + * @param vob the VOB name + */ + public void setVOB(String vob) { + mVOB = vob; + } + + /** + * Get VOB name + * + * @return String containing VOB name + */ + public String getVOB() { + return mVOB; + } + + /** + * Set the replace flag + * + * @param repl the status to set the flag to + */ + public void setReplace(boolean repl) { + mReplace = repl; + } + + /** + * Get replace flag status + * + * @return boolean containing status of replace flag + */ + public boolean getReplace() { + return mReplace; + } + + /** + * Set the global flag + * + * @param glob the status to set the flag to + */ + public void setGlobal(boolean glob) { + mGlobal = glob; + } + + /** + * Get global flag status + * + * @return boolean containing status of global flag + */ + public boolean getGlobal() { + return mGlobal; + } + + /** + * Set the ordinary flag + * + * @param ordinary the status to set the flag to + */ + public void setOrdinary(boolean ordinary) { + mOrdinary = ordinary; + } + + /** + * Get ordinary flag status + * + * @return boolean containing status of ordinary flag + */ + public boolean getOrdinary() { + return mOrdinary; + } + + /** + * Set the pbranch flag + * + * @param pbranch the status to set the flag to + */ + public void setPbranch(boolean pbranch) { + mPbranch = pbranch; + } + + /** + * Get pbranch flag status + * + * @return boolean containing status of pbranch flag + */ + public boolean getPbranch() { + return mPbranch; + } + + /** + * Set the shared flag + * + * @param shared the status to set the flag to + */ + public void setShared(boolean shared) { + mShared = shared; + } + + /** + * Get shared flag status + * + * @return boolean containing status of shared flag + */ + public boolean getShared() { + return mShared; + } + + /** + * Set comment string + * + * @param comment the comment string + */ + public void setComment(String comment) { + mComment = comment; + } + + /** + * Get comment string + * + * @return String containing the comment + */ + public String getComment() { + return mComment; + } + + /** + * Set comment file + * + * @param cfile the path to the comment file + */ + public void setCommentFile(String cfile) { + mCfile = cfile; + } + + /** + * Get comment file + * + * @return String containing the path to the comment file + */ + public String getCommentFile() { + return mCfile; + } + + + /** + * Get the 'comment' command + * + * @param cmd containing the command line string with or + * without the comment flag and string appended + */ + private void getCommentCommand(Commandline cmd) { + 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()); + } + } + + /** + * Get the 'commentfile' command + * + * @param cmd containing the command line string with or + * without the commentfile flag and file appended + */ + private void getCommentFileCommand(Commandline cmd) { + 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()); + } + } + + /** + * Get the type-name specifier + * + * @return the 'type-name-specifier' command if the attribute was + * specified, otherwise an empty string + */ + private String getTypeSpecifier() { + String typenm = null; + + typenm = getTypeName(); + if (getVOB() != null) { + typenm += "@" + getVOB(); + } + + return typenm; + } + + + /** + * -replace flag -- replace existing label definition of the same type + */ + public static final String FLAG_REPLACE = "-replace"; + /** + * -global flag -- creates a label type that is global to the VOB or to VOBs that use this VOB + */ + public static final String FLAG_GLOBAL = "-global"; + /** + * -ordinary flag -- creates a label type that can be used only in the current VOB + */ + public static final String FLAG_ORDINARY = "-ordinary"; + /** + * -pbranch flag -- allows label type to be used once per branch + */ + public static final String FLAG_PBRANCH = "-pbranch"; + /** + * -shared flag -- sets the way mastership is checked by ClearCase + */ + public static final String FLAG_SHARED = "-shared"; + /** + * -c flag -- comment to attach to the file + */ + public static final String FLAG_COMMENT = "-c"; + /** + * -cfile flag -- file containing a comment to attach to the file + */ + public static final String FLAG_COMMENTFILE = "-cfile"; + /** + * -nc flag -- no comment is specified + */ + public static final String FLAG_NOCOMMENT = "-nc"; + +} + diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCRmtype.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCRmtype.java new file mode 100644 index 00000000..cef0c3a5 --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCRmtype.java @@ -0,0 +1,373 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.tools.ant.taskdefs.optional.clearcase; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.taskdefs.Execute; +import org.apache.tools.ant.types.Commandline; + +/** + * Task to perform rmtype command to ClearCase. + * <p> + * The following attributes are interpreted: + * <table border="1"> + * <tr> + * <th>Attribute</th> + * <th>Values</th> + * <th>Required</th> + * </tr> + * <tr> + * <td>typekind</td> + * <td>The kind of type to create. Valid types are:<br> + * attype attribute type<br> + * brtype branch type<br> + * eltype element type<br> + * hltype hyperlink type<br> + * lbtype label type<br> + * trtype trigger type<br> + * </td> + * <td>Yes</td> + * <tr> + * <tr> + * <td>typename</td> + * <td>The name of the type to remove</td> + * <td>Yes</td> + * <tr> + * <tr> + * <td>vob</td> + * <td>Name of the VOB</td> + * <td>No</td> + * <tr> + * <tr> + * <td>ignore</td> + * <td>Used with trigger types only. Forces removal of trigger type + * even if a pre-operation trigger would prevent its removal</td> + * <td>No</td> + * <tr> + * <tr> + * <td>rmall</td> + * <td>Removes all instances of a type and the type object itself</td> + * <td>No</td> + * <tr> + * <tr> + * <td>comment</td> + * <td>Specify a comment. Only one of comment or cfile may be used.</td> + * <td>No</td> + * <tr> + * <tr> + * <td>commentfile</td> + * <td>Specify a file containing a comment. Only one of comment or cfile + * may be used.</td> + * <td>No</td> + * <tr> + * <tr> + * <td>failonerr</td> + * <td>Throw an exception if the command fails. Default is true</td> + * <td>No</td> + * <tr> + * </table> + * + */ +public class CCRmtype extends ClearCase { + private String mTypeKind = null; + private String mTypeName = null; + private String mVOB = null; + private String mComment = null; + private String mCfile = null; + private boolean mRmall = false; + private boolean mIgnore = false; + + /** + * Executes the task. + * <p> + * Builds a command line to execute cleartool and then calls Exec's run method + * to execute the command line. + * @throws BuildException if the command fails and failonerr is set to true + */ + public void execute() throws BuildException { + Commandline commandLine = new Commandline(); + int result = 0; + + // Check for required attributes + if (getTypeKind() == null) { + throw new BuildException("Required attribute TypeKind not specified"); + } + if (getTypeName() == null) { + throw new BuildException("Required attribute TypeName not specified"); + } + + // build the command line from what we got. the format is + // cleartool rmtype [options...] type-selector... + // as specified in the CLEARTOOL help + commandLine.setExecutable(getClearToolCommand()); + commandLine.createArgument().setValue(COMMAND_RMTYPE); + + checkOptions(commandLine); + + if (!getFailOnErr()) { + getProject().log("Ignoring any errors that occur for: " + + getTypeSpecifier(), Project.MSG_VERBOSE); + } + result = run(commandLine); + if (Execute.isFailure(result) && getFailOnErr()) { + String msg = "Failed executing: " + commandLine.toString(); + throw new BuildException(msg, getLocation()); + } + } + + + /** + * Check the command line options. + */ + private void checkOptions(Commandline cmd) { + if (getIgnore()) { + // -ignore + cmd.createArgument().setValue(FLAG_IGNORE); + } + if (getRmAll()) { + // -rmall -force + cmd.createArgument().setValue(FLAG_RMALL); + cmd.createArgument().setValue(FLAG_FORCE); + } + if (getComment() != null) { + // -c + getCommentCommand(cmd); + } else { + if (getCommentFile() != null) { + // -cfile + getCommentFileCommand(cmd); + } else { + cmd.createArgument().setValue(FLAG_NOCOMMENT); + } + } + + // type-kind:type-name + cmd.createArgument().setValue(getTypeSpecifier()); + } + + /** + * Set the ignore flag + * + * @param ignore the status to set the flag to + */ + public void setIgnore(boolean ignore) { + mIgnore = ignore; + } + + /** + * Get ignore flag status + * + * @return boolean containing status of ignore flag + */ + public boolean getIgnore() { + return mIgnore; + } + + /** + * Set rmall flag + * + * @param rmall the status to set the flag to + */ + public void setRmAll(boolean rmall) { + mRmall = rmall; + } + + /** + * Get rmall flag status + * + * @return boolean containing status of rmall flag + */ + public boolean getRmAll() { + return mRmall; + } + + /** + * Set comment string + * + * @param comment the comment string + */ + public void setComment(String comment) { + mComment = comment; + } + + /** + * Get comment string + * + * @return String containing the comment + */ + public String getComment() { + return mComment; + } + + /** + * Set comment file + * + * @param cfile the path to the comment file + */ + public void setCommentFile(String cfile) { + mCfile = cfile; + } + + /** + * Get comment file + * + * @return String containing the path to the comment file + */ + public String getCommentFile() { + return mCfile; + } + + /** + * Set type-kind string + * + * @param tk the type-kind string + */ + public void setTypeKind(String tk) { + mTypeKind = tk; + } + + /** + * Get type-kind string + * + * @return String containing the type-kind + */ + public String getTypeKind() { + return mTypeKind; + } + + /** + * Set type-name string + * + * @param tn the type-name string + */ + public void setTypeName(String tn) { + mTypeName = tn; + } + + /** + * Get type-name string + * + * @return String containing the type-name + */ + public String getTypeName() { + return mTypeName; + } + + /** + * Set the VOB name + * + * @param vob the VOB name + */ + public void setVOB(String vob) { + mVOB = vob; + } + + /** + * Get VOB name + * + * @return String containing VOB name + */ + public String getVOB() { + return mVOB; + } + + /** + * Get the 'type-specifier' string + * + * @return the 'type-kind:type-name@vob' specifier + * + */ + private String getTypeSpecifier() { + String tkind = getTypeKind(); + String tname = getTypeName(); + String typeSpec = null; + + // Return the type-selector + typeSpec = tkind + ":" + tname; + if (getVOB() != null) { + typeSpec += "@" + getVOB(); + } + return typeSpec; + } + + /** + * Get the 'comment' command + * + * @param cmd containing the command line string with or + * without the comment flag and string appended + */ + private void getCommentCommand(Commandline cmd) { + 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()); + } + } + + /** + * Get the 'commentfile' command + * + * @param cmd containing the command line string with or + * without the commentfile flag and file appended + */ + private void getCommentFileCommand(Commandline cmd) { + 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()); + } + } + + + /** + * -ignore flag -- ignore pre-trigger operations when removing a trigger type + */ + public static final String FLAG_IGNORE = "-ignore"; + /** + * -rmall flag -- removes all instances of a type and the type object itself + */ + public static final String FLAG_RMALL = "-rmall"; + /** + * -force flag -- suppresses confirmation prompts + */ + public static final String FLAG_FORCE = "-force"; + /** + * -c flag -- comment to attach to the file + */ + public static final String FLAG_COMMENT = "-c"; + /** + * -cfile flag -- file containing a comment to attach to the file + */ + public static final String FLAG_COMMENTFILE = "-cfile"; + /** + * -nc flag -- no comment is specified + */ + public static final String FLAG_NOCOMMENT = "-nc"; + +} + diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnCheckout.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnCheckout.java new file mode 100644 index 00000000..3c00e1af --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnCheckout.java @@ -0,0 +1,141 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.tools.ant.taskdefs.optional.clearcase; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.taskdefs.Execute; +import org.apache.tools.ant.types.Commandline; + +/** + * Performs ClearCase UnCheckout command. + * + * <p> + * The following attributes are interpreted: + * <table border="1"> + * <tr> + * <th>Attribute</th> + * <th>Values</th> + * <th>Required</th> + * </tr> + * <tr> + * <td>viewpath</td> + * <td>Path to the ClearCase view file or directory that the command will operate on</td> + * <td>No</td> + * <tr> + * <tr> + * <td>keepcopy</td> + * <td>Specifies whether to keep a copy of the file with a .keep extension or not</td> + * <td>No</td> + * <tr> + * <tr> + * <td>failonerr</td> + * <td>Throw an exception if the command fails. Default is true</td> + * <td>No</td> + * <tr> + * </table> + * + */ +public class CCUnCheckout extends ClearCase { + private boolean mKeep = false; + + /** + * Executes the task. + * <p> + * Builds a command line to execute cleartool and then calls Exec's run method + * to execute the command line. + * @throws BuildException if the command fails and failonerr is set to true + */ + public void execute() throws BuildException { + Commandline commandLine = new Commandline(); + Project aProj = getProject(); + int result = 0; + + // 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 uncheckout [options...] [viewpath ...] + // as specified in the CLEARTOOL.EXE help + commandLine.setExecutable(getClearToolCommand()); + commandLine.createArgument().setValue(COMMAND_UNCHECKOUT); + + checkOptions(commandLine); + + if (!getFailOnErr()) { + getProject().log("Ignoring any errors that occur for: " + + getViewPathBasename(), Project.MSG_VERBOSE); + } + result = run(commandLine); + if (Execute.isFailure(result) && getFailOnErr()) { + String msg = "Failed executing: " + commandLine.toString(); + throw new BuildException(msg, getLocation()); + } + } + + + /** + * Check the command line options. + */ + private void checkOptions(Commandline cmd) { + // ClearCase items + if (getKeepCopy()) { + // -keep + cmd.createArgument().setValue(FLAG_KEEPCOPY); + } else { + // -rm + cmd.createArgument().setValue(FLAG_RM); + } + + // viewpath + cmd.createArgument().setValue(getViewPath()); + } + + /** + * If true, keep a copy of the file with a .keep extension. + * + * @param keep the status to set the flag to + */ + public void setKeepCopy(boolean keep) { + mKeep = keep; + } + + /** + * Get keepcopy flag status + * + * @return boolean containing status of keep flag + */ + public boolean getKeepCopy() { + return mKeep; + } + + + /** + * -keep flag -- keep a copy of the file with .keep extension + */ + public static final String FLAG_KEEPCOPY = "-keep"; + /** + * -rm flag -- remove the copy of the file + */ + public static final String FLAG_RM = "-rm"; + +} + diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnlock.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnlock.java new file mode 100644 index 00000000..4ca3e890 --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnlock.java @@ -0,0 +1,260 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.tools.ant.taskdefs.optional.clearcase; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.taskdefs.Execute; +import org.apache.tools.ant.types.Commandline; + +/** + * TODO: + * comment field doesn't include all options yet + */ + +/** + * Performs a ClearCase Unlock command. + * + * <p> + * The following attributes are interpreted: + * <table border="1"> + * <tr> + * <th>Attribute</th> + * <th>Values</th> + * <th>Required</th> + * </tr> + * <tr> + * <td>comment</td> + * <td>Specifies how to populate comments fields</td> + * <td>No</td> + * <tr> + * <tr> + * <td>pname</td> + * <td>Specifies the object pathname to be unlocked.</td> + * <td>No</td> + * <tr> + * <td>objselect</td> + * <td>This variable is obsolete. Should use <i>objsel</i> instead.</td> + * <td>no</td> + * <tr> + * <tr> + * <td>objsel</td> + * <td>Specifies the object(s) to be unlocked.</td> + * <td>No</td> + * <tr> + * <tr> + * <td>failonerr</td> + * <td>Throw an exception if the command fails. Default is true</td> + * <td>No</td> + * <tr> + * + * </table> + * + */ +public class CCUnlock extends ClearCase { + private String mComment = null; + private String mPname = null; + + /** + * Executes the task. + * <p> + * Builds a command line to execute cleartool and then calls Exec's run method + * to execute the command line. + * @throws BuildException if the command fails and failonerr is set to true + */ + public void execute() throws BuildException { + Commandline commandLine = new Commandline(); + Project aProj = getProject(); + int result = 0; + + // 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 lock [options...] + // as specified in the CLEARTOOL.EXE help + commandLine.setExecutable(getClearToolCommand()); + commandLine.createArgument().setValue(COMMAND_UNLOCK); + + // Check the command line options + checkOptions(commandLine); + + // For debugging + // System.out.println(commandLine.toString()); + + if (!getFailOnErr()) { + getProject().log("Ignoring any errors that occur for: " + + getOpType(), Project.MSG_VERBOSE); + } + result = run(commandLine); + if (Execute.isFailure(result) && getFailOnErr()) { + String msg = "Failed executing: " + commandLine.toString(); + throw new BuildException(msg, getLocation()); + } + } + + /** + * Check the command line options. + */ + private void checkOptions(Commandline cmd) { + // ClearCase items + getCommentCommand(cmd); + + if (getObjSelect() == null && getPname() == null) { + throw new BuildException("Should select either an element " + + "(pname) or an object (objselect)"); + } + getPnameCommand(cmd); + // object selector + if (getObjSelect() != null) { + cmd.createArgument().setValue(getObjSelect()); + } + } + + /** + * Sets how comments should be written + * for the event record(s) + * + * @param comment comment method to use + */ + public void setComment(String comment) { + mComment = comment; + } + + /** + * Get comment method + * + * @return String containing the desired comment method + */ + public String getComment() { + return mComment; + } + + /** + * Sets the pathname to be locked + * + * @param pname pathname to be locked + */ + public void setPname(String pname) { + mPname = pname; + } + + /** + * Get the pathname to be locked + * + * @return String containing the pathname to be locked + */ + public String getPname() { + return mPname; + } + + /** + * Sets the object(s) to be locked + * + * @param objselect objects to be locked + */ + public void setObjselect(String objselect) { + setObjSelect(objselect); + } + + /** + * Sets the object(s) to be locked + * + * @param objsel objects to be locked + * @since ant 1.6.1 + */ + public void setObjSel(String objsel) { + setObjSelect(objsel); + } + + /** + * Get list of objects to be locked + * + * @return String containing the objects to be locked + */ + public String getObjselect() { + return getObjSelect(); + } + + /** + * Get the 'comment' command + * + * @param cmd containing the command line string with or without the + * comment flag and value appended + */ + private void getCommentCommand(Commandline cmd) { + if (getComment() == null) { + return; + } else { + /* 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()); + } + } + + /** + * Get the 'pname' command + * + * @param cmd containing the command line string with or without the + * pname flag and value appended + */ + private void getPnameCommand(Commandline cmd) { + if (getPname() == null) { + return; + } else { + /* 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_PNAME); + cmd.createArgument().setValue(getPname()); + } + } + + /** + * Return which object/pname is being operated on + * + * @return String containing the object/pname being worked on + */ + private String getOpType() { + + if (getPname() != null) { + return getPname(); + } else { + return getObjSelect(); + } + } + + /** + * -comment flag -- method to use for commenting events + */ + public static final String FLAG_COMMENT = "-comment"; + /** + * -pname flag -- pathname to lock + */ + public static final String FLAG_PNAME = "-pname"; +} + diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUpdate.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUpdate.java new file mode 100644 index 00000000..712efdca --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUpdate.java @@ -0,0 +1,331 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.tools.ant.taskdefs.optional.clearcase; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.taskdefs.Execute; +import org.apache.tools.ant.types.Commandline; + +/** + * Performs a ClearCase Update command. + * + * <p> + * The following attributes are interpreted: + * <table border="1"> + * <tr> + * <th>Attribute</th> + * <th>Values</th> + * <th>Required</th> + * </tr> + * <tr> + * <td>viewpath</td> + * <td>Path to the ClearCase view file or directory that the command will operate on</td> + * <td>No</td> + * <tr> + * <tr> + * <td>graphical</td> + * <td>Displays a graphical dialog during the update</td> + * <td>No</td> + * <tr> + * <tr> + * <td>log</td> + * <td>Specifies a log file for ClearCase to write to</td> + * <td>No</td> + * <tr> + * <tr> + * <td>overwrite</td> + * <td>Specifies whether to overwrite hijacked files or not</td> + * <td>No</td> + * <tr> + * <tr> + * <td>rename</td> + * <td>Specifies that hijacked files should be renamed with a .keep extension</td> + * <td>No</td> + * <tr> + * <tr> + * <td>currenttime</td> + * <td>Specifies that modification time should be written as the current + * time. Either currenttime or preservetime can be specified.</td> + * <td>No</td> + * <tr> + * <tr> + * <td>preservetime</td> + * <td>Specifies that modification time should preserved from the VOB + * time. Either currenttime or preservetime can be specified.</td> + * <td>No</td> + * <tr> + * <tr> + * <td>failonerr</td> + * <td>Throw an exception if the command fails. Default is true</td> + * <td>No</td> + * <tr> + * </table> + * + */ +public class CCUpdate extends ClearCase { + private boolean mGraphical = false; + private boolean mOverwrite = false; + private boolean mRename = false; + private boolean mCtime = false; + private boolean mPtime = false; + private String mLog = null; + + /** + * Executes the task. + * <p> + * Builds a command line to execute cleartool and then calls Exec's run method + * to execute the command line. + * @throws BuildException if the command fails and failonerr is set to true + */ + public void execute() throws BuildException { + Commandline commandLine = new Commandline(); + Project aProj = getProject(); + int result = 0; + + // 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 update [options...] [viewpath ...] + // as specified in the CLEARTOOL.EXE help + commandLine.setExecutable(getClearToolCommand()); + commandLine.createArgument().setValue(COMMAND_UPDATE); + + // Check the command line options + checkOptions(commandLine); + + // For debugging + getProject().log(commandLine.toString(), Project.MSG_DEBUG); + + if (!getFailOnErr()) { + getProject().log("Ignoring any errors that occur for: " + + getViewPathBasename(), Project.MSG_VERBOSE); + } + result = run(commandLine); + if (Execute.isFailure(result) && getFailOnErr()) { + String msg = "Failed executing: " + commandLine.toString(); + throw new BuildException(msg, getLocation()); + } + } + + /** + * Check the command line options. + */ + private void checkOptions(Commandline cmd) { + // ClearCase items + if (getGraphical()) { + // -graphical + cmd.createArgument().setValue(FLAG_GRAPHICAL); + } else { + if (getOverwrite()) { + // -overwrite + cmd.createArgument().setValue(FLAG_OVERWRITE); + } else { + if (getRename()) { + // -rename + cmd.createArgument().setValue(FLAG_RENAME); + } else { + // -noverwrite + cmd.createArgument().setValue(FLAG_NOVERWRITE); + } + } + + if (getCurrentTime()) { + // -ctime + cmd.createArgument().setValue(FLAG_CURRENTTIME); + } else { + if (getPreserveTime()) { + // -ptime + cmd.createArgument().setValue(FLAG_PRESERVETIME); + } + } + + // -log logname + getLogCommand(cmd); + } + + // viewpath + cmd.createArgument().setValue(getViewPath()); + } + + /** + * If true, displays a graphical dialog during the update. + * + * @param graphical the status to set the flag to + */ + public void setGraphical(boolean graphical) { + mGraphical = graphical; + } + + /** + * Get graphical flag status + * + * @return boolean containing status of graphical flag + */ + public boolean getGraphical() { + return mGraphical; + } + + /** + * If true, overwrite hijacked files. + * + * @param ow the status to set the flag to + */ + public void setOverwrite(boolean ow) { + mOverwrite = ow; + } + + /** + * Get overwrite hijacked files status + * + * @return boolean containing status of overwrite flag + */ + public boolean getOverwrite() { + return mOverwrite; + } + + /** + * If true, hijacked files are renamed with a .keep extension. + * + * @param ren the status to set the flag to + */ + public void setRename(boolean ren) { + mRename = ren; + } + + /** + * Get rename hijacked files status + * + * @return boolean containing status of rename flag + */ + public boolean getRename() { + return mRename; + } + + /** + * If true, modification time should be written as the current time. + * Either currenttime or preservetime can be specified. + * + * @param ct the status to set the flag to + */ + public void setCurrentTime(boolean ct) { + mCtime = ct; + } + + /** + * Get current time status + * + * @return boolean containing status of current time flag + */ + public boolean getCurrentTime() { + return mCtime; + } + + /** + * If true, modification time should be preserved from the VOB time. + * Either currenttime or preservetime can be specified. + * + * @param pt the status to set the flag to + */ + public void setPreserveTime(boolean pt) { + mPtime = pt; + } + + /** + * Get preserve time status + * + * @return boolean containing status of preserve time flag + */ + public boolean getPreserveTime() { + return mPtime; + } + + /** + * Sets the log file where cleartool records + * the status of the command. + * + * @param log the path to the log file + */ + public void setLog(String log) { + mLog = log; + } + + /** + * Get log file + * + * @return String containing the path to the log file + */ + public String getLog() { + return mLog; + } + + + /** + * Get the 'log' command + * + * @param cmd containing the command line string with or without the log flag and path appended + */ + private void getLogCommand(Commandline cmd) { + if (getLog() == null) { + return; + } else { + /* 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_LOG); + cmd.createArgument().setValue(getLog()); + } + } + + /** + * -graphical flag -- display graphical dialog during update operation + */ + public static final String FLAG_GRAPHICAL = "-graphical"; + /** + * -log flag -- file to log status to + */ + public static final String FLAG_LOG = "-log"; + /** + * -overwrite flag -- overwrite hijacked files + */ + public static final String FLAG_OVERWRITE = "-overwrite"; + /** + * -noverwrite flag -- do not overwrite hijacked files + */ + public static final String FLAG_NOVERWRITE = "-noverwrite"; + /** + * -rename flag -- rename hijacked files with .keep extension + */ + public static final String FLAG_RENAME = "-rename"; + /** + * -ctime flag -- modified time is written as the current time + */ + public static final String FLAG_CURRENTTIME = "-ctime"; + /** + * -ptime flag -- modified time is written as the VOB time + */ + public static final String FLAG_PRESERVETIME = "-ptime"; + +} + diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java new file mode 100644 index 00000000..d81e505c --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java @@ -0,0 +1,242 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.tools.ant.taskdefs.optional.clearcase; + +import java.io.File; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.Task; +import org.apache.tools.ant.taskdefs.ExecTask; +import org.apache.tools.ant.taskdefs.Execute; +import org.apache.tools.ant.taskdefs.LogStreamHandler; +import org.apache.tools.ant.types.Commandline; +import org.apache.tools.ant.util.FileUtils; + + + +/** + * A base class for creating tasks for executing commands on ClearCase. + * <p> + * 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. + * </p> + * <p> + * 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. + * </p> + * + */ +public abstract class ClearCase extends Task { + private String mClearToolDir = ""; + private String mviewPath = null; + private String mobjSelect = null; + private static int pcnt = 0; + private boolean mFailonerr = true; + /** + * Set the directory where the cleartool executable is located. + * + * @param dir the directory containing the cleartool executable + */ + public final void setClearToolDir(String dir) { + mClearToolDir = FileUtils.translatePath(dir); + } + + /** + * Builds and returns the command string to execute cleartool + * + * @return String containing path to the executable + */ + protected final String getClearToolCommand() { + String toReturn = mClearToolDir; + if (!toReturn.equals("") && !toReturn.endsWith("/")) { + toReturn += "/"; + } + + toReturn += CLEARTOOL_EXE; + + return toReturn; + } + + /** + * Set the path to the item in a ClearCase view to operate on. + * + * @param viewPath Path to the view directory or file + */ + public final void setViewPath(String viewPath) { + mviewPath = viewPath; + } + + /** + * Get the path to the item in a clearcase view + * + * @return mviewPath + */ + public String getViewPath() { + return mviewPath; + } + + /** + * Get the basename path of the item in a clearcase view + * + * @return basename + */ + public String getViewPathBasename() { + return (new File(mviewPath)).getName(); + } + + /** + * Set the object to operate on. + * + * @param objSelect object to operate on + */ + public final void setObjSelect(String objSelect) { + mobjSelect = objSelect; + } + + /** + * Get the object to operate on + * + * @return mobjSelect + */ + public String getObjSelect() { + return mobjSelect; + } + + /** + * Execute the given command are return success or failure + * @param cmd command line to execute + * @return the exit status of the subprocess or <code>INVALID</code> + */ + protected int run(Commandline cmd) { + 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()); + } + } + + /** + * Execute the given command, and return it's output + * @param cmdline command line to execute + * @return output of the command line + */ + protected String runS(Commandline cmdline) { + 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); + } + /** + * If true, command will throw an exception on failure. + * + * @param failonerr the status to set the flag to + * @since ant 1.6.1 + */ + public void setFailOnErr(boolean failonerr) { + mFailonerr = failonerr; + } + + /** + * Get failonerr flag status + * + * @return boolean containing status of failonerr flag + * @since ant 1.6.1 + */ + public boolean getFailOnErr() { + return mFailonerr; + } + + /** + * Constant for the thing to execute + */ + private static final String CLEARTOOL_EXE = "cleartool"; + /** + * The 'Update' command + */ + public static final String COMMAND_UPDATE = "update"; + /** + * The 'Checkout' command + */ + public static final String COMMAND_CHECKOUT = "checkout"; + /** + * The 'Checkin' command + */ + public static final String COMMAND_CHECKIN = "checkin"; + /** + * The 'UndoCheckout' command + */ + public static final String COMMAND_UNCHECKOUT = "uncheckout"; + /** + * The 'Lock' command + */ + public static final String COMMAND_LOCK = "lock"; + /** + * The 'Unlock' command + */ + public static final String COMMAND_UNLOCK = "unlock"; + /** + * The 'Mkbl' command + */ + public static final String COMMAND_MKBL = "mkbl"; + /** + * The 'Mklabel' command + */ + public static final String COMMAND_MKLABEL = "mklabel"; + /** + * The 'Mklbtype' command + */ + public static final String COMMAND_MKLBTYPE = "mklbtype"; + /** + * The 'Rmtype' command + */ + public static final String COMMAND_RMTYPE = "rmtype"; + /** + * The 'LsCheckout' command + */ + public static final String COMMAND_LSCO = "lsco"; + /** + * The 'Mkelem' command + */ + public static final String COMMAND_MKELEM = "mkelem"; + /** + * The 'Mkattr' command + */ + public static final String COMMAND_MKATTR = "mkattr"; + /** + * The 'Mkdir' command + */ + public static final String COMMAND_MKDIR = "mkdir"; + +} + |