Browse Source

- Added an extra option to 'failonerr' to each ClearCase task/command.

- Extended the functionality of cccheckout. It can check (notco) to see if
  the desired element is already checked out to the current view. Thus it
  won't attempt to check it out again.
- Added three new ClearCase commands: ccmkattr, ccmkdir, ccmkelem
- Checkstyle
PR: 26253
Submitted by: Sean Egan (sean at cm-logic dot com)


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275943 13f79535-47bb-0310-9956-ffa450edef68
master
Antoine Levy-Lambert 21 years ago
parent
commit
5f41947fea
18 changed files with 2047 additions and 351 deletions
  1. +8
    -0
      WHATSNEW
  2. +289
    -13
      docs/manual/OptionalTasks/clearcase.html
  3. +1
    -1
      docs/manual/tasksoverview.html
  4. +3
    -0
      src/main/org/apache/tools/ant/taskdefs/defaults.properties
  5. +30
    -20
      src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckin.java
  6. +104
    -46
      src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckout.java
  7. +70
    -49
      src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCLock.java
  8. +462
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkattr.java
  9. +38
    -33
      src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkbl.java
  10. +274
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkdir.java
  11. +461
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkelem.java
  12. +38
    -39
      src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMklabel.java
  13. +42
    -41
      src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMklbtype.java
  14. +36
    -33
      src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCRmtype.java
  15. +17
    -7
      src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnCheckout.java
  16. +57
    -34
      src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnlock.java
  17. +32
    -21
      src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUpdate.java
  18. +85
    -14
      src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java

+ 8
- 0
WHATSNEW View File

@@ -47,6 +47,14 @@ Other changes:
* add description attributes to macrodef attributes and elements.
Bugzilla Report 24711.

* Extending ClearCase Tasks :
- Added an extra option to 'failonerr' to each ClearCase task/command.
- Extended the functionality of cccheckout. It can check (notco) to see if
the desired element is already checked out to the current view. Thus it
won't attempt to check it out again.
- Added three new ClearCase commands: ccmkattr, ccmkdir, ccmkelem
Bugzilla Report 26253.

Changes from Ant 1.5.4 to Ant 1.6.0
===================================



+ 289
- 13
docs/manual/OptionalTasks/clearcase.html View File

@@ -3,14 +3,16 @@
<head>
<meta http-equiv="Content-Language" content="en-us">
<title>Clearcase Tasks</title>
<link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css">
</head>

<body>
<h1>Ant ClearCase Tasks</h1>
<p>by:<br>
Curtis White (cwhite at aracnet dot com),<br>
Sean P. Kane (spkane at genomatica dot com), and<br>
Rob Anderson (Anderson.Rob at vectorscm dot com)</p>
Sean P. Kane (spkane at genomatica dot com),<br>
Rob Anderson (Anderson.Rob at vectorscm dot com), and<br>
Sean Egan (sean at cm-logic dot com)</p>

<p>Version 1.6 - 02/25/2003</p>

@@ -27,7 +29,10 @@ Rob Anderson (Anderson.Rob at vectorscm dot com)</p>
<li><A href="#ccrmtype">CCRmtype</a>
<li><A href="#cclock">CCLock</a>
<li><A href="#ccunlock">CCUnlock</a>
<li><A href="#ccmkbl">CCMkbl</a></li>
<li><A href="#ccmkbl">CCMkbl</a>
<li><A href="#ccmkattr">CCMkattr</a>
<li><A href="#ccmkdir">CCMkdir</a>
<li><A href="#ccmkelem">CCMkelem</a></li>

</ul>

@@ -90,6 +95,11 @@ Task to perform a "cleartool checkin" command to ClearCase.
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>
<h3>Examples</h3>
<blockquote>
@@ -162,7 +172,19 @@ Task to perform a "cleartool checkout" command to ClearCase.
<td>Specify a file containing a comment. Only one of comment or
commentfile may be used.</td>
<td>No</td>
</tr>
</tr>
<tr>
<td>notco</td>
<td>Fail if it's already checked out to the current view. Set to false to ignore it.<br>
Since ant 1.6.1</td>
<td>No</td>
</tr>
<tr>
<td>failonerr</td>
<td>Throw an exception if the command fails. Default is true.<br>
Since ant 1.6.1</td>
<td>No</td>
</tr>
</table>
<h3>Examples</h3>
<blockquote>
@@ -201,6 +223,12 @@ Task to perform a UnCheckout command to ClearCase.
extension or not</td>
<td>No</td>
</tr>
<tr>
<td>failonerr</td>
<td>Throw an exception if the command fails. Default is true<br>
Since ant 1.6.1</td>
<td>No</td>
</tr>
</table>
<h3>Examples</h3>
<blockquote>
@@ -262,6 +290,12 @@ Task to perform an "cleartool update" command to ClearCase.
specified.</td>
<td>No</td>
</tr>
<tr>
<td>failonerr</td>
<td>Throw an exception if the command fails. Default is true.<br>
Since ant 1.6.1</td>
<td>No</td>
</tr>
</table>
<h3>Examples</h3>
<blockquote>
@@ -337,6 +371,12 @@ Task to perform a "mklbtype" command to ClearCase.
<td>Specify a file containing a comment. Only one of comment or cfile may be used.</td>
<td>No</td>
<tr></tr>
<tr>
<td>failonerr</td>
<td>Throw an exception if the command fails. Default is true<br>
Since ant 1.6.1</td>
<td>No</td>
</tr>
</table>

<h3>Examples</h3>
@@ -403,6 +443,12 @@ Task to perform a "mklabel" command to ClearCase.
<td>Specify a file containing a comment. Only one of comment or cfile may be used.</td>
<td>No</td>
<tr></tr>
<tr>
<td>failonerr</td>
<td>Throw an exception if the command fails. Default is true<br>
Since ant 1.6.1</td>
<td>No</td>
</tr>
</table>

<h3>Examples</h3>
@@ -488,6 +534,12 @@ Task to perform a "rmtype" command to ClearCase.
<td>Specify a file containing a comment. Only one of comment or cfile may be used.</td>
<td>No</td>
<tr></tr>
<tr>
<td>failonerr</td>
<td>Throw an exception if the command fails. Default is true
Since ant 1.6.1</td>
<td>No</td>
</tr>
</table>

<h3>Examples</h3>
@@ -537,19 +589,31 @@ Task to perform a "cleartool lock" command to ClearCase.
<tr>
<td>pname</td>
<td>Specifies the object pathname to be locked.</td>
<td>Yes</td>
<td>No</td>
<tr>
<td>objselect</td>
<td>Specifies the object(s) to be locked.</td>
<td>Yes</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 locked.<br>
Since ant 1.6.1</td>
<td>No</td>
<tr>
<tr>
<td>failonerr</td>
<td>Throw an exception if the command fails. Default is true.<br>
Since ant 1.6.1</td>
<td>No</td>
</tr>

</table>
<h3>Examples</h3>
<blockquote>
<pre>
&lt;cclock
objselect="stream:Application_Integration@\MyProject_PVOB"
objsel="stream:Application_Integration@\MyProject_PVOB"
/&gt;
</pre>
</blockquote>
@@ -574,19 +638,31 @@ Task to perform a "cleartool unlock" command to ClearCase.
<tr>
<td>pname</td>
<td>Specifies the object pathname to be unlocked.</td>
<td>Yes</td>
<td>No</td>
<tr>
<td>objselect</td>
<td>Specifies the object(s) to be unlocked.</td>
<td>Yes</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.<br>
Since ant 1.6.1</td>
<td>No</td>
<tr>
<tr>
<td>failonerr</td>
<td>Throw an exception if the command fails. Default is true.<br>
Since ant 1.6.1</td>
<td>No</td>
</tr>

</table>
<h3>Examples</h3>
<blockquote>
<pre>
&lt;ccunlock
objselect="stream:Application_Integration@\MyProject_PVOB"
objsel="stream:Application_Integration@\MyProject_PVOB"
/&gt;
</pre>
</blockquote>
@@ -641,6 +717,12 @@ previous baseline.</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.<br>
Since ant 1.6.1</td>
<td>No</td>
</tr>
</table>
<h3>Examples</h3>
<blockquote>
@@ -658,7 +740,201 @@ even if it is <i>identical</i> to a previous baseline. The new baseline with be
incremental and named "Application_Baseline_AUTO".</p>
<hr>

<p align="center">Copyright © 2000-2003 Apache Software Foundation. All rights
<h2><a name="ccmkattr">CCMkattr</a></h2>
<h3>Description</h3>
Task to perform a &quot;cleartool mkattr&quot; command to ClearCase.<br>
Since ant 1.6.1
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<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>
<h3>Examples</h3>
<blockquote>
<pre>
&lt;ccmkattr viewpath=&quot;c:/views/viewdir/afile&quot;
typename=&quot;BugFix&quot;
typevalue=&quot;34445&quot;
/&gt;
</pre>
</blockquote>
<p>Does a ClearCase <i>mkattr</i> on the file <i>c:/views/viewdir/afile</i> and
attaches the attribute <i>BugFix</i> with a value of <i>34445</i> to it.</p>
<hr>

<h2><a name="ccmkdir">CCMkdir</a></h2>
<h3>Description</h3>
Task to perform a &quot;cleartool mkdir&quot; command to ClearCase.<br>
Since ant 1.6.1
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<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>
<h3>Examples</h3>
<blockquote>
<pre>
&lt;ccmkdir viewpath=&quot;c:/views/viewdir/adir&quot;
nochcekout=&quot;true&quot;
comment=&quot;Some comment text&quot;/&gt;
</pre>
</blockquote>
<p>Does a ClearCase <i>mkdir</i> on the dir <i>c:/views/viewdir/adir</i> and
does not automatically check it out.</p>
<hr>

<h2><a name="ccmkelem">CCMkelem</a></h2>
<h3>Description</h3>
Task to perform a &quot;cleartool mkelem&quot; command to ClearCase.<br>
Since ant 1.6.1
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<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>
<h3>Examples</h3>
<blockquote>
<pre>
&lt;ccmkelem viewpath=&quot;c:/views/viewdir/afile&quot;
eltype=&quot;text_file&quot;
checkin=&quot;true&quot;
comment=&quot;Some comment text&quot;/&gt;
</pre>
</blockquote>
<p>Does a ClearCase <i>mkelem</i> on the file <i>c:/views/viewdir/afile</i> with
element type <i>text_file</i>. It also checks in the file after creation.</p>
<hr>

<p align="center">Copyright &copy; 2000-2004 Apache Software Foundation. All rights
reserved.</p>
</body>
</html>

+ 1
- 1
docs/manual/tasksoverview.html View File

@@ -1150,7 +1150,7 @@ documentation.</p>
<tr valign="top">
<td nowrap><a href="OptionalTasks/clearcase.html">ClearCase</a></td>
<td><p>Tasks to perform the ClearCase cleartool <i>checkin</i>, <i>checkout</i>,
<i>uncheckout</i>, <i>update</i>, <i>lock</i>, <i>unlock</i>, <i>mklbtype</i>, <i>rmtype</i>, <i>mklabel</i>, and <i>mkbl</i> commands.</p></td>
<i>uncheckout</i>, <i>update</i>, <i>lock</i>, <i>unlock</i>, <i>mklbtype</i>, <i>rmtype</i>, <i>mklabel</i>, <i>mkattr</i>, <i>mkdir</i>, <i>mkelem</i>, and <i>mkbl</i> commands.</p></td>
</tr>

<tr valign="top">


+ 3
- 0
src/main/org/apache/tools/ant/taskdefs/defaults.properties View File

@@ -155,6 +155,9 @@ ccrmtype=org.apache.tools.ant.taskdefs.optional.clearcase.CCRmtype
cclock=org.apache.tools.ant.taskdefs.optional.clearcase.CCLock
ccunlock=org.apache.tools.ant.taskdefs.optional.clearcase.CCUnlock
ccmkbl=org.apache.tools.ant.taskdefs.optional.clearcase.CCMkbl
ccmkattr=org.apache.tools.ant.taskdefs.optional.clearcase.CCMkattr
ccmkelem=org.apache.tools.ant.taskdefs.optional.clearcase.CCMkelem
ccmkdir=org.apache.tools.ant.taskdefs.optional.clearcase.CCMkdir
sound=org.apache.tools.ant.taskdefs.optional.sound.SoundTask
junitreport=org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator
blgenclient=org.apache.tools.ant.taskdefs.optional.ejb.BorlandGenerateClient


+ 30
- 20
src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckin.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000,2002-2003 The Apache Software Foundation. All rights
* Copyright (c) 2000,2002-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -105,23 +105,29 @@ import org.apache.tools.ant.types.Commandline;
* <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>
*
* @author Curtis White
*/
public class CCCheckin extends ClearCase {
private String m_Comment = null;
private String m_Cfile = null;
private boolean m_Nwarn = false;
private boolean m_Ptime = false;
private boolean m_Keep = false;
private boolean m_Identical = true;
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();
@@ -141,8 +147,12 @@ public class CCCheckin extends ClearCase {

checkOptions(commandLine);

if (!getFailOnErr()) {
getProject().log("Ignoring any errors that occur for: "
+ getViewPathBasename(), Project.MSG_VERBOSE);
}
result = run(commandLine);
if (Execute.isFailure(result)) {
if (Execute.isFailure(result) && getFailOnErr()) {
String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, getLocation());
}
@@ -196,7 +206,7 @@ public class CCCheckin extends ClearCase {
* @param comment the comment string
*/
public void setComment(String comment) {
m_Comment = comment;
mComment = comment;
}

/**
@@ -205,7 +215,7 @@ public class CCCheckin extends ClearCase {
* @return String containing the comment
*/
public String getComment() {
return m_Comment;
return mComment;
}

/**
@@ -214,7 +224,7 @@ public class CCCheckin extends ClearCase {
* @param cfile the path to the comment file
*/
public void setCommentFile(String cfile) {
m_Cfile = cfile;
mCfile = cfile;
}

/**
@@ -223,7 +233,7 @@ public class CCCheckin extends ClearCase {
* @return String containing the path to the comment file
*/
public String getCommentFile() {
return m_Cfile;
return mCfile;
}

/**
@@ -232,7 +242,7 @@ public class CCCheckin extends ClearCase {
* @param nwarn the status to set the flag to
*/
public void setNoWarn(boolean nwarn) {
m_Nwarn = nwarn;
mNwarn = nwarn;
}

/**
@@ -241,7 +251,7 @@ public class CCCheckin extends ClearCase {
* @return boolean containing status of nwarn flag
*/
public boolean getNoWarn() {
return m_Nwarn;
return mNwarn;
}

/**
@@ -250,7 +260,7 @@ public class CCCheckin extends ClearCase {
* @param ptime the status to set the flag to
*/
public void setPreserveTime(boolean ptime) {
m_Ptime = ptime;
mPtime = ptime;
}

/**
@@ -259,7 +269,7 @@ public class CCCheckin extends ClearCase {
* @return boolean containing status of preservetime flag
*/
public boolean getPreserveTime() {
return m_Ptime;
return mPtime;
}

/**
@@ -268,7 +278,7 @@ public class CCCheckin extends ClearCase {
* @param keep the status to set the flag to
*/
public void setKeepCopy(boolean keep) {
m_Keep = keep;
mKeep = keep;
}

/**
@@ -277,7 +287,7 @@ public class CCCheckin extends ClearCase {
* @return boolean containing status of keepcopy flag
*/
public boolean getKeepCopy() {
return m_Keep;
return mKeep;
}

/**
@@ -287,7 +297,7 @@ public class CCCheckin extends ClearCase {
* @param identical the status to set the flag to
*/
public void setIdentical(boolean identical) {
m_Identical = identical;
mIdentical = identical;
}

/**
@@ -296,7 +306,7 @@ public class CCCheckin extends ClearCase {
* @return boolean containing status of identical flag
*/
public boolean getIdentical() {
return m_Identical;
return mIdentical;
}




+ 104
- 46
src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCCheckout.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* Copyright (c) 2000-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -60,8 +60,6 @@ import org.apache.tools.ant.taskdefs.Execute;
import org.apache.tools.ant.types.Commandline;




/**
* Performs ClearCase checkout.
*
@@ -118,25 +116,37 @@ import org.apache.tools.ant.types.Commandline;
* <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>
*
* @author Curtis White
* @author Curtis White (Extended by Sean Egan)
*/
public class CCCheckout extends ClearCase {
private boolean m_Reserved = true;
private String m_Out = null;
private boolean m_Ndata = false;
private String m_Branch = null;
private boolean m_Version = false;
private boolean m_Nwarn = false;
private String m_Comment = null;
private String m_Cfile = null;
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();
@@ -155,15 +165,51 @@ public class CCCheckout extends ClearCase {
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)) {
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.
*/
@@ -218,6 +264,9 @@ public class CCCheckout extends ClearCase {

// viewpath
cmd.createArgument().setValue(getViewPath());

// Print out info about the notco option
// System.out.println( "Notco: " + (getNotco() ? "yes" : "no") );
}

/**
@@ -226,7 +275,7 @@ public class CCCheckout extends ClearCase {
* @param reserved the status to set the flag to
*/
public void setReserved(boolean reserved) {
m_Reserved = reserved;
mReserved = reserved;
}

/**
@@ -235,16 +284,37 @@ public class CCCheckout extends ClearCase {
* @return boolean containing status of reserved flag
*/
public boolean getReserved() {
return m_Reserved;
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) {
m_Out = outf;
mOut = outf;
}

/**
@@ -253,7 +323,7 @@ public class CCCheckout extends ClearCase {
* @return String containing the path to the out file
*/
public String getOut() {
return m_Out;
return mOut;
}

/**
@@ -263,7 +333,7 @@ public class CCCheckout extends ClearCase {
* @param ndata the status to set the flag to
*/
public void setNoData(boolean ndata) {
m_Ndata = ndata;
mNdata = ndata;
}

/**
@@ -272,7 +342,7 @@ public class CCCheckout extends ClearCase {
* @return boolean containing status of ndata flag
*/
public boolean getNoData() {
return m_Ndata;
return mNdata;
}

/**
@@ -281,7 +351,7 @@ public class CCCheckout extends ClearCase {
* @param branch the name of the branch
*/
public void setBranch(String branch) {
m_Branch = branch;
mBranch = branch;
}

/**
@@ -290,7 +360,7 @@ public class CCCheckout extends ClearCase {
* @return String containing the name of the branch
*/
public String getBranch() {
return m_Branch;
return mBranch;
}

/**
@@ -299,7 +369,7 @@ public class CCCheckout extends ClearCase {
* @param version the status to set the flag to
*/
public void setVersion(boolean version) {
m_Version = version;
mVersion = version;
}

/**
@@ -308,7 +378,7 @@ public class CCCheckout extends ClearCase {
* @return boolean containing status of version flag
*/
public boolean getVersion() {
return m_Version;
return mVersion;
}

/**
@@ -317,7 +387,7 @@ public class CCCheckout extends ClearCase {
* @param nwarn the status to set the flag to
*/
public void setNoWarn(boolean nwarn) {
m_Nwarn = nwarn;
mNwarn = nwarn;
}

/**
@@ -326,7 +396,7 @@ public class CCCheckout extends ClearCase {
* @return boolean containing status of nwarn flag
*/
public boolean getNoWarn() {
return m_Nwarn;
return mNwarn;
}

/**
@@ -335,7 +405,7 @@ public class CCCheckout extends ClearCase {
* @param comment the comment string
*/
public void setComment(String comment) {
m_Comment = comment;
mComment = comment;
}

/**
@@ -344,7 +414,7 @@ public class CCCheckout extends ClearCase {
* @return String containing the comment
*/
public String getComment() {
return m_Comment;
return mComment;
}

/**
@@ -353,7 +423,7 @@ public class CCCheckout extends ClearCase {
* @param cfile the path to the comment file
*/
public void setCommentFile(String cfile) {
m_Cfile = cfile;
mCfile = cfile;
}

/**
@@ -362,16 +432,13 @@ public class CCCheckout extends ClearCase {
* @return String containing the path to the comment file
*/
public String getCommentFile() {
return m_Cfile;
return mCfile;
}

/**
* Get the 'out' command
*
* @return the 'out' command if the attribute was specified,
* otherwise an empty string
*
* @param CommandLine containing the command line string with or
* @param cmd containing the command line string with or
* without the out flag and path appended
*/
private void getOutCommand(Commandline cmd) {
@@ -389,10 +456,7 @@ public class CCCheckout extends ClearCase {
/**
* Get the 'branch' command
*
* @return the 'branch' command if the attribute was specified,
* otherwise an empty string
*
* @param CommandLine containing the command line string with or
* @param cmd containing the command line string with or
without the branch flag and name appended
*/
private void getBranchCommand(Commandline cmd) {
@@ -411,10 +475,7 @@ public class CCCheckout extends ClearCase {
/**
* Get the 'comment' command
*
* @return the 'comment' command if the attribute was specified,
* otherwise an empty string
*
* @param CommandLine containing the command line string with or
* @param cmd containing the command line string with or
* without the comment flag and string appended
*/
private void getCommentCommand(Commandline cmd) {
@@ -432,10 +493,7 @@ public class CCCheckout extends ClearCase {
/**
* Get the 'cfile' command
*
* @return the 'cfile' command if the attribute was specified,
* otherwise an empty string
*
* @param CommandLine containing the command line string with or
* @param cmd containing the command line string with or
* without the cfile flag and file appended
*/
private void getCommentFileCommand(Commandline cmd) {


+ 70
- 49
src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCLock.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* Copyright (c) 2003-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -85,12 +85,12 @@ import org.apache.tools.ant.types.Commandline;
* <tr>
* <tr>
* <td>nusers</td>
* <td>Specifies user(s) who can still modify the object</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 should be marked obsolete</td>
* <td>Specifies that the object/pname should be marked obsolete</td>
* <td>No</td>
* <tr>
* <tr>
@@ -100,31 +100,41 @@ import org.apache.tools.ant.types.Commandline;
* <tr>
* <tr>
* <td>pname</td>
* <td>Specifies the object pathname to be locked.</td>
* <td>Yes</td>
* <td>Specifies the pathname to be locked.</td>
* <td>No</td>
* <tr>
* <td>objselect</td>
* <td>Specifies the object(s) to be locked.</td>
* <td>Yes</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>
*
* @author Sean P. Kane (Based on work by: Curtis White)
*/
public class CCLock extends ClearCase {
private boolean m_Replace = false;
private boolean m_Obsolete = false;
private String m_Comment = null;
private String m_Nusers = null;
private String m_Pname = null;
private String m_Objselect = null;
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();
@@ -146,12 +156,16 @@ public class CCLock extends ClearCase {
checkOptions(commandLine);

// For debugging
System.out.println(commandLine.toString());
// 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)) {
if (Execute.isFailure(result) && getFailOnErr()) {
String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, location);
throw new BuildException(msg, getLocation());
}
}

@@ -168,12 +182,19 @@ private void checkOptions(Commandline cmd) {
// -obsolete
cmd.createArgument().setValue(FLAG_OBSOLETE);
} else {
getNusersCommand(cmd);
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
cmd.createArgument().setValue(getObjselect());
// object selector
if (getObjselect() != null) {
cmd.createArgument().setValue(getObjselect());
}
}

/**
@@ -182,7 +203,7 @@ private void checkOptions(Commandline cmd) {
* @param replace the status to set the flag to
*/
public void setReplace(boolean replace) {
m_Replace = replace;
mReplace = replace;
}

/**
@@ -191,7 +212,7 @@ private void checkOptions(Commandline cmd) {
* @return boolean containing status of replace flag
*/
public boolean getReplace() {
return m_Replace;
return mReplace;
}

/**
@@ -200,7 +221,7 @@ private void checkOptions(Commandline cmd) {
* @param obsolete the status to set the flag to
*/
public void setObsolete(boolean obsolete) {
m_Obsolete = obsolete;
mObsolete = obsolete;
}

/**
@@ -209,7 +230,7 @@ private void checkOptions(Commandline cmd) {
* @return boolean containing status of obsolete flag
*/
public boolean getObsolete() {
return m_Obsolete;
return mObsolete;
}

/**
@@ -219,7 +240,7 @@ private void checkOptions(Commandline cmd) {
* @param nusers users excluded from lock
*/
public void setNusers(String nusers) {
m_Nusers = nusers;
mNusers = nusers;
}

/**
@@ -228,7 +249,7 @@ private void checkOptions(Commandline cmd) {
* @return String containing the list of users excluded from lock
*/
public String getNusers() {
return m_Nusers;
return mNusers;
}

/**
@@ -238,7 +259,7 @@ private void checkOptions(Commandline cmd) {
* @param comment comment method to use
*/
public void setComment(String comment) {
m_Comment = comment;
mComment = comment;
}

/**
@@ -247,7 +268,7 @@ private void checkOptions(Commandline cmd) {
* @return String containing the desired comment method
*/
public String getComment() {
return m_Comment;
return mComment;
}

/**
@@ -256,7 +277,7 @@ private void checkOptions(Commandline cmd) {
* @param pname pathname to be locked
*/
public void setPname(String pname) {
m_Pname = pname;
mPname = pname;
}

/**
@@ -265,7 +286,17 @@ private void checkOptions(Commandline cmd) {
* @return String containing the pathname to be locked
*/
public String getPname() {
return m_Pname;
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;
}

/**
@@ -274,7 +305,7 @@ private void checkOptions(Commandline cmd) {
* @param objselect objects to be locked
*/
public void setObjselect(String objselect) {
m_Objselect = objselect;
mObjselect = objselect;
}

/**
@@ -283,7 +314,7 @@ private void checkOptions(Commandline cmd) {
* @return String containing the objects to be locked
*/
public String getObjselect() {
return m_Objselect;
return mObjselect;
}

/**
@@ -347,22 +378,16 @@ private void checkOptions(Commandline cmd) {
}

/**
* Get the 'pname' command
* Return which object/pname is being operated on
*
* @param cmd containing the command line string with or
* without the pname flag and value appended
* @return String containing the object/pname being worked on
*/
private void getObjselectCommand(Commandline cmd) {
if (getObjselect() == null) {
return;
private String getOpType() {

if (getPname() != null) {
return getPname();
} 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_OBJSELECT);
cmd.createArgument().setValue(getPname());
return getObjselect();
}
}

@@ -386,9 +411,5 @@ private void checkOptions(Commandline cmd) {
* -pname flag -- pathname to lock
*/
public static final String FLAG_PNAME = "-pname";
/**
* object-selector option -- list of objects to lock
*/
public static final String FLAG_OBJSELECT = "";
}


+ 462
- 0
src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkattr.java View File

@@ -0,0 +1,462 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "Ant" and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/

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;
import org.apache.tools.ant.taskdefs.condition.Os;

/**
* 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>
*
* @author Sean Egan
*/
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";
}


+ 38
- 33
src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkbl.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* Copyright (c) 2003-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -107,18 +107,23 @@ previous baseline.</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>
*
* @author Robert Anderson
*/
public class CCMkbl extends ClearCase {
private String m_Comment = null;
private String m_Cfile = null;
private String m_BaselineRootName = null;
private boolean m_Nwarn = false;
private boolean m_Identical = true;
private boolean m_Full = false;
private boolean m_Nlabel = false;
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;


/**
@@ -126,6 +131,7 @@ public class CCMkbl extends ClearCase {
* <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();
@@ -145,10 +151,14 @@ public class CCMkbl extends ClearCase {

checkOptions(commandLine);

if (!getFailOnErr()) {
getProject().log("Ignoring any errors that occur for: "
+ getBaselineRootName(), Project.MSG_VERBOSE);
}
result = run(commandLine);
if (Execute.isFailure(result)) {
if (Execute.isFailure(result) && getFailOnErr()) {
String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, location);
throw new BuildException(msg, getLocation());
}
}

@@ -199,7 +209,7 @@ public class CCMkbl extends ClearCase {
* @param comment the comment string
*/
public void setComment(String comment) {
m_Comment = comment;
mComment = comment;
}

/**
@@ -208,7 +218,7 @@ public class CCMkbl extends ClearCase {
* @return String containing the comment
*/
public String getComment() {
return m_Comment;
return mComment;
}

/**
@@ -217,7 +227,7 @@ public class CCMkbl extends ClearCase {
* @param cfile the path to the comment file
*/
public void setCommentFile(String cfile) {
m_Cfile = cfile;
mCfile = cfile;
}

/**
@@ -226,16 +236,16 @@ public class CCMkbl extends ClearCase {
* @return String containing the path to the comment file
*/
public String getCommentFile() {
return m_Cfile;
return mCfile;
}

/**
* Set baseline_root_name
*
* @param baseline_root_name the name of the baseline
* @param baselineRootName the name of the baseline
*/
public void setBaselineRootName(String baseline_root_name) {
m_BaselineRootName = baseline_root_name;
public void setBaselineRootName(String baselineRootName) {
mBaselineRootName = baselineRootName;
}

/**
@@ -244,7 +254,7 @@ public class CCMkbl extends ClearCase {
* @return String containing the name of the baseline
*/
public String getBaselineRootName() {
return m_BaselineRootName;
return mBaselineRootName;
}

/**
@@ -255,7 +265,7 @@ public class CCMkbl extends ClearCase {
* @param nwarn the status to set the flag to
*/
public void setNoWarn(boolean nwarn) {
m_Nwarn = nwarn;
mNwarn = nwarn;
}

/**
@@ -264,7 +274,7 @@ public class CCMkbl extends ClearCase {
* @return boolean containing status of nwarn flag
*/
public boolean getNoWarn() {
return m_Nwarn;
return mNwarn;
}

/**
@@ -273,7 +283,7 @@ public class CCMkbl extends ClearCase {
* @param identical the status to set the flag to
*/
public void setIdentical(boolean identical) {
m_Identical = identical;
mIdentical = identical;
}

/**
@@ -282,7 +292,7 @@ public class CCMkbl extends ClearCase {
* @return boolean containing status of identical flag
*/
public boolean getIdentical() {
return m_Identical;
return mIdentical;
}

/**
@@ -291,7 +301,7 @@ public class CCMkbl extends ClearCase {
* @param full the status to set the flag to
*/
public void setFull(boolean full) {
m_Full = full;
mFull = full;
}

/**
@@ -300,7 +310,7 @@ public class CCMkbl extends ClearCase {
* @return boolean containing status of full flag
*/
public boolean getFull() {
return m_Full;
return mFull;
}

/**
@@ -309,7 +319,7 @@ public class CCMkbl extends ClearCase {
* @param nlabel the status to set the flag to
*/
public void setNlabel(boolean nlabel) {
m_Nlabel = nlabel;
mNlabel = nlabel;
}

/**
@@ -318,16 +328,14 @@ public class CCMkbl extends ClearCase {
* @return boolean containing status of nlabel flag
*/
public boolean getNlabel() {
return m_Nlabel;
return mNlabel;
}


/**
* Get the 'comment' command
*
* @return the 'comment' command if the attribute was specified,
* otherwise an empty string
*
* @param CommandLine containing the command line string with or
* @param cmd containing the command line string with or
* without the comment flag and string appended
*/
private void getCommentCommand(Commandline cmd) {
@@ -345,9 +353,6 @@ public class CCMkbl extends ClearCase {
/**
* Get the 'commentfile' command
*
* @return the 'commentfile' command if the attribute was specified,
* otherwise an empty string
*
* @param cmd CommandLine containing the command line string with or
* without the commentfile flag and file appended
*/


+ 274
- 0
src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkdir.java View File

@@ -0,0 +1,274 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "Ant" and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/

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>
*
* @author Sean Egan
*/
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";
}


+ 461
- 0
src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkelem.java View File

@@ -0,0 +1,461 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "Ant" and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/

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>
*
* @author Sean Egan
*/
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";
}


+ 38
- 39
src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMklabel.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* Copyright (c) 2003-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -109,24 +109,30 @@ import org.apache.tools.ant.types.Commandline;
* <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>
*
* @author Curtis White
*/
public class CCMklabel extends ClearCase {
private boolean m_Replace = false;
private boolean m_Recurse = false;
private String m_Version = null;
private String m_TypeName = null;
private String m_VOB = null;
private String m_Comment = null;
private String m_Cfile = null;
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();
@@ -151,10 +157,14 @@ public class CCMklabel extends ClearCase {

checkOptions(commandLine);

if (!getFailOnErr()) {
getProject().log("Ignoring any errors that occur for: "
+ getViewPathBasename(), Project.MSG_VERBOSE);
}
result = run(commandLine);
if (Execute.isFailure(result)) {
if (Execute.isFailure(result) && getFailOnErr()) {
String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, location);
throw new BuildException(msg, getLocation());
}
}

@@ -206,7 +216,7 @@ public class CCMklabel extends ClearCase {
* @param replace the status to set the flag to
*/
public void setReplace(boolean replace) {
m_Replace = replace;
mReplace = replace;
}

/**
@@ -215,7 +225,7 @@ public class CCMklabel extends ClearCase {
* @return boolean containing status of replace flag
*/
public boolean getReplace() {
return m_Replace;
return mReplace;
}

/**
@@ -224,7 +234,7 @@ public class CCMklabel extends ClearCase {
* @param recurse the status to set the flag to
*/
public void setRecurse(boolean recurse) {
m_Recurse = recurse;
mRecurse = recurse;
}

/**
@@ -233,7 +243,7 @@ public class CCMklabel extends ClearCase {
* @return boolean containing status of recurse flag
*/
public boolean getRecurse() {
return m_Recurse;
return mRecurse;
}

/**
@@ -242,7 +252,7 @@ public class CCMklabel extends ClearCase {
* @param version the status to set the flag to
*/
public void setVersion(String version) {
m_Version = version;
mVersion = version;
}

/**
@@ -251,7 +261,7 @@ public class CCMklabel extends ClearCase {
* @return boolean containing status of version flag
*/
public String getVersion() {
return m_Version;
return mVersion;
}

/**
@@ -260,7 +270,7 @@ public class CCMklabel extends ClearCase {
* @param comment the comment string
*/
public void setComment(String comment) {
m_Comment = comment;
mComment = comment;
}

/**
@@ -269,7 +279,7 @@ public class CCMklabel extends ClearCase {
* @return String containing the comment
*/
public String getComment() {
return m_Comment;
return mComment;
}

/**
@@ -278,7 +288,7 @@ public class CCMklabel extends ClearCase {
* @param cfile the path to the comment file
*/
public void setCommentFile(String cfile) {
m_Cfile = cfile;
mCfile = cfile;
}

/**
@@ -287,7 +297,7 @@ public class CCMklabel extends ClearCase {
* @return String containing the path to the comment file
*/
public String getCommentFile() {
return m_Cfile;
return mCfile;
}

/**
@@ -296,7 +306,7 @@ public class CCMklabel extends ClearCase {
* @param tn the type name
*/
public void setTypeName(String tn) {
m_TypeName = tn;
mTypeName = tn;
}

/**
@@ -305,7 +315,7 @@ public class CCMklabel extends ClearCase {
* @return String containing type name
*/
public String getTypeName() {
return m_TypeName;
return mTypeName;
}

/**
@@ -314,7 +324,7 @@ public class CCMklabel extends ClearCase {
* @param vob the VOB name
*/
public void setVOB(String vob) {
m_VOB = vob;
mVOB = vob;
}

/**
@@ -323,15 +333,13 @@ public class CCMklabel extends ClearCase {
* @return String containing VOB name
*/
public String getVOB() {
return m_VOB;
return mVOB;
}


/**
* Get the 'version' command
*
* @return the 'version' command if the attribute was specified,
* otherwise an empty string
*
* @param cmd CommandLine containing the command line string with or
* without the version flag and string appended
*/
@@ -350,10 +358,7 @@ public class CCMklabel extends ClearCase {
/**
* Get the 'comment' command
*
* @return the 'comment' command if the attribute was
* specified, otherwise an empty string
*
* @param CommandLine containing the command line string with or
* @param cmd containing the command line string with or
* without the comment flag and string appended
*/
private void getCommentCommand(Commandline cmd) {
@@ -371,10 +376,7 @@ public class CCMklabel extends ClearCase {
/**
* Get the 'commentfile' command
*
* @return the 'commentfile' command if the attribute was specified,
* otherwise an empty string
*
* @param CommandLine containing the command line string with or
* @param cmd containing the command line string with or
* without the commentfile flag and file appended
*/
private void getCommentFileCommand(Commandline cmd) {
@@ -392,10 +394,7 @@ public class CCMklabel extends ClearCase {
/**
* Get the type-name
*
* @return the 'type-name-specifier' command if the attribute
* was specified, otherwise an empty string
*
* @param CommandLine containing the command line string with or
* @param cmd containing the command line string with or
* without the type-name
*/
private void getTypeCommand(Commandline cmd) {


+ 42
- 41
src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMklbtype.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* Copyright (c) 2003-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -121,26 +121,32 @@ import org.apache.tools.ant.types.Commandline;
* 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>
*
* @author Curtis White
*/
public class CCMklbtype extends ClearCase {
private String m_TypeName = null;
private String m_VOB = null;
private String m_Comment = null;
private String m_Cfile = null;
private boolean m_Replace = false;
private boolean m_Global = false;
private boolean m_Ordinary = true;
private boolean m_Pbranch = false;
private boolean m_Shared = false;
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();
@@ -160,10 +166,14 @@ public class CCMklbtype extends ClearCase {

checkOptions(commandLine);

if (!getFailOnErr()) {
getProject().log("Ignoring any errors that occur for: "
+ getTypeSpecifier(), Project.MSG_VERBOSE);
}
result = run(commandLine);
if (Execute.isFailure(result)) {
if (Execute.isFailure(result) && getFailOnErr()) {
String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, location);
throw new BuildException(msg, getLocation());
}
}

@@ -220,7 +230,7 @@ public class CCMklbtype extends ClearCase {
* @param tn the type-name string
*/
public void setTypeName(String tn) {
m_TypeName = tn;
mTypeName = tn;
}

/**
@@ -229,7 +239,7 @@ public class CCMklbtype extends ClearCase {
* @return String containing the type-name
*/
public String getTypeName() {
return m_TypeName;
return mTypeName;
}

/**
@@ -238,7 +248,7 @@ public class CCMklbtype extends ClearCase {
* @param vob the VOB name
*/
public void setVOB(String vob) {
m_VOB = vob;
mVOB = vob;
}

/**
@@ -247,7 +257,7 @@ public class CCMklbtype extends ClearCase {
* @return String containing VOB name
*/
public String getVOB() {
return m_VOB;
return mVOB;
}

/**
@@ -256,7 +266,7 @@ public class CCMklbtype extends ClearCase {
* @param repl the status to set the flag to
*/
public void setReplace(boolean repl) {
m_Replace = repl;
mReplace = repl;
}

/**
@@ -265,7 +275,7 @@ public class CCMklbtype extends ClearCase {
* @return boolean containing status of replace flag
*/
public boolean getReplace() {
return m_Replace;
return mReplace;
}

/**
@@ -274,7 +284,7 @@ public class CCMklbtype extends ClearCase {
* @param glob the status to set the flag to
*/
public void setGlobal(boolean glob) {
m_Global = glob;
mGlobal = glob;
}

/**
@@ -283,7 +293,7 @@ public class CCMklbtype extends ClearCase {
* @return boolean containing status of global flag
*/
public boolean getGlobal() {
return m_Global;
return mGlobal;
}

/**
@@ -292,7 +302,7 @@ public class CCMklbtype extends ClearCase {
* @param ordinary the status to set the flag to
*/
public void setOrdinary(boolean ordinary) {
m_Ordinary = ordinary;
mOrdinary = ordinary;
}

/**
@@ -301,7 +311,7 @@ public class CCMklbtype extends ClearCase {
* @return boolean containing status of ordinary flag
*/
public boolean getOrdinary() {
return m_Ordinary;
return mOrdinary;
}

/**
@@ -310,7 +320,7 @@ public class CCMklbtype extends ClearCase {
* @param pbranch the status to set the flag to
*/
public void setPbranch(boolean pbranch) {
m_Pbranch = pbranch;
mPbranch = pbranch;
}

/**
@@ -319,7 +329,7 @@ public class CCMklbtype extends ClearCase {
* @return boolean containing status of pbranch flag
*/
public boolean getPbranch() {
return m_Pbranch;
return mPbranch;
}

/**
@@ -328,7 +338,7 @@ public class CCMklbtype extends ClearCase {
* @param shared the status to set the flag to
*/
public void setShared(boolean shared) {
m_Shared = shared;
mShared = shared;
}

/**
@@ -337,7 +347,7 @@ public class CCMklbtype extends ClearCase {
* @return boolean containing status of shared flag
*/
public boolean getShared() {
return m_Shared;
return mShared;
}

/**
@@ -346,7 +356,7 @@ public class CCMklbtype extends ClearCase {
* @param comment the comment string
*/
public void setComment(String comment) {
m_Comment = comment;
mComment = comment;
}

/**
@@ -355,7 +365,7 @@ public class CCMklbtype extends ClearCase {
* @return String containing the comment
*/
public String getComment() {
return m_Comment;
return mComment;
}

/**
@@ -364,7 +374,7 @@ public class CCMklbtype extends ClearCase {
* @param cfile the path to the comment file
*/
public void setCommentFile(String cfile) {
m_Cfile = cfile;
mCfile = cfile;
}

/**
@@ -373,17 +383,14 @@ public class CCMklbtype extends ClearCase {
* @return String containing the path to the comment file
*/
public String getCommentFile() {
return m_Cfile;
return mCfile;
}


/**
* Get the 'comment' command
*
* @return the 'comment' command if the attribute was specified,
* otherwise an empty string
*
* @param CommandLine containing the command line string with or
* @param cmd containing the command line string with or
* without the comment flag and string appended
*/
private void getCommentCommand(Commandline cmd) {
@@ -401,10 +408,7 @@ public class CCMklbtype extends ClearCase {
/**
* Get the 'commentfile' command
*
* @return the 'commentfile' command if the attribute was specified,
* otherwise an empty string
*
* @param CommandLine containing the command line string with or
* @param cmd containing the command line string with or
* without the commentfile flag and file appended
*/
private void getCommentFileCommand(Commandline cmd) {
@@ -424,9 +428,6 @@ public class CCMklbtype extends ClearCase {
*
* @return the 'type-name-specifier' command if the attribute was
* specified, otherwise an empty string
*
* @param CommandLine containing the command line string with or
* without the type-name
*/
private String getTypeSpecifier() {
String typenm = null;


+ 36
- 33
src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCRmtype.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* Copyright (c) 2003-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -113,24 +113,30 @@ import org.apache.tools.ant.types.Commandline;
* 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>
*
* @author Curtis White
*/
public class CCRmtype extends ClearCase {
private String m_TypeKind = null;
private String m_TypeName = null;
private String m_VOB = null;
private String m_Comment = null;
private String m_Cfile = null;
private boolean m_Rmall = false;
private boolean m_Ignore = false;
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();
@@ -153,10 +159,14 @@ public class CCRmtype extends ClearCase {

checkOptions(commandLine);

if (!getFailOnErr()) {
getProject().log("Ignoring any errors that occur for: "
+ getTypeSpecifier(), Project.MSG_VERBOSE);
}
result = run(commandLine);
if (Execute.isFailure(result)) {
if (Execute.isFailure(result) && getFailOnErr()) {
String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, location);
throw new BuildException(msg, getLocation());
}
}

@@ -196,7 +206,7 @@ public class CCRmtype extends ClearCase {
* @param ignore the status to set the flag to
*/
public void setIgnore(boolean ignore) {
m_Ignore = ignore;
mIgnore = ignore;
}

/**
@@ -205,7 +215,7 @@ public class CCRmtype extends ClearCase {
* @return boolean containing status of ignore flag
*/
public boolean getIgnore() {
return m_Ignore;
return mIgnore;
}

/**
@@ -214,7 +224,7 @@ public class CCRmtype extends ClearCase {
* @param rmall the status to set the flag to
*/
public void setRmAll(boolean rmall) {
m_Rmall = rmall;
mRmall = rmall;
}

/**
@@ -223,7 +233,7 @@ public class CCRmtype extends ClearCase {
* @return boolean containing status of rmall flag
*/
public boolean getRmAll() {
return m_Rmall;
return mRmall;
}

/**
@@ -232,7 +242,7 @@ public class CCRmtype extends ClearCase {
* @param comment the comment string
*/
public void setComment(String comment) {
m_Comment = comment;
mComment = comment;
}

/**
@@ -241,7 +251,7 @@ public class CCRmtype extends ClearCase {
* @return String containing the comment
*/
public String getComment() {
return m_Comment;
return mComment;
}

/**
@@ -250,7 +260,7 @@ public class CCRmtype extends ClearCase {
* @param cfile the path to the comment file
*/
public void setCommentFile(String cfile) {
m_Cfile = cfile;
mCfile = cfile;
}

/**
@@ -259,7 +269,7 @@ public class CCRmtype extends ClearCase {
* @return String containing the path to the comment file
*/
public String getCommentFile() {
return m_Cfile;
return mCfile;
}

/**
@@ -268,7 +278,7 @@ public class CCRmtype extends ClearCase {
* @param tk the type-kind string
*/
public void setTypeKind(String tk) {
m_TypeKind = tk;
mTypeKind = tk;
}

/**
@@ -277,7 +287,7 @@ public class CCRmtype extends ClearCase {
* @return String containing the type-kind
*/
public String getTypeKind() {
return m_TypeKind;
return mTypeKind;
}

/**
@@ -286,7 +296,7 @@ public class CCRmtype extends ClearCase {
* @param tn the type-name string
*/
public void setTypeName(String tn) {
m_TypeName = tn;
mTypeName = tn;
}

/**
@@ -295,7 +305,7 @@ public class CCRmtype extends ClearCase {
* @return String containing the type-name
*/
public String getTypeName() {
return m_TypeName;
return mTypeName;
}

/**
@@ -304,7 +314,7 @@ public class CCRmtype extends ClearCase {
* @param vob the VOB name
*/
public void setVOB(String vob) {
m_VOB = vob;
mVOB = vob;
}

/**
@@ -313,7 +323,7 @@ public class CCRmtype extends ClearCase {
* @return String containing VOB name
*/
public String getVOB() {
return m_VOB;
return mVOB;
}

/**
@@ -321,7 +331,6 @@ public class CCRmtype extends ClearCase {
*
* @return the 'type-kind:type-name@vob' specifier
*
* @param CommandLine containing the command line string
*/
private String getTypeSpecifier() {
String tkind = getTypeKind();
@@ -339,10 +348,7 @@ public class CCRmtype extends ClearCase {
/**
* Get the 'comment' command
*
* @return the 'comment' command if the attribute was specified,
* otherwise an empty string
*
* @param CommandLine containing the command line string with or
* @param cmd containing the command line string with or
* without the comment flag and string appended
*/
private void getCommentCommand(Commandline cmd) {
@@ -360,10 +366,7 @@ public class CCRmtype extends ClearCase {
/**
* Get the 'commentfile' command
*
* @return the 'commentfile' command if the attribute was specified,
* otherwise an empty string
*
* @param CommandLine containing the command line string with or
* @param cmd containing the command line string with or
* without the commentfile flag and file appended
*/
private void getCommentFileCommand(Commandline cmd) {


+ 17
- 7
src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnCheckout.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* Copyright (c) 2000-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -80,18 +80,24 @@ import org.apache.tools.ant.types.Commandline;
* <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>
*
* @author Curtis White
*/
public class CCUnCheckout extends ClearCase {
private boolean m_Keep = false;
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();
@@ -111,8 +117,12 @@ public class CCUnCheckout extends ClearCase {

checkOptions(commandLine);

if (!getFailOnErr()) {
getProject().log("Ignoring any errors that occur for: "
+ getViewPathBasename(), Project.MSG_VERBOSE);
}
result = run(commandLine);
if (Execute.isFailure(result)) {
if (Execute.isFailure(result) && getFailOnErr()) {
String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, getLocation());
}
@@ -142,7 +152,7 @@ public class CCUnCheckout extends ClearCase {
* @param keep the status to set the flag to
*/
public void setKeepCopy(boolean keep) {
m_Keep = keep;
mKeep = keep;
}

/**
@@ -151,15 +161,15 @@ public class CCUnCheckout extends ClearCase {
* @return boolean containing status of keep flag
*/
public boolean getKeepCopy() {
return m_Keep;
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";


+ 57
- 34
src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnlock.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* Copyright (c) 2003-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -84,11 +84,21 @@ import org.apache.tools.ant.types.Commandline;
* <tr>
* <td>pname</td>
* <td>Specifies the object pathname to be unlocked.</td>
* <td>Yes</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>Yes</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>
@@ -96,15 +106,16 @@ import org.apache.tools.ant.types.Commandline;
* @author Sean P. Kane (Based on work by: Curtis White)
*/
public class CCUnlock extends ClearCase {
private String m_Comment = null;
private String m_Pname = null;
private String m_Objselect = null;
private String mComment = 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();
@@ -126,12 +137,16 @@ public class CCUnlock extends ClearCase {
checkOptions(commandLine);

// For debugging
System.out.println(commandLine.toString());
// 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)) {
if (Execute.isFailure(result) && getFailOnErr()) {
String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, location);
throw new BuildException(msg, getLocation());
}
}

@@ -141,9 +156,16 @@ public class CCUnlock extends ClearCase {
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
cmd.createArgument().setValue(getObjselect());
// object selector
if (getObjselect() != null) {
cmd.createArgument().setValue(getObjselect());
}
}

/**
@@ -153,7 +175,7 @@ private void checkOptions(Commandline cmd) {
* @param comment comment method to use
*/
public void setComment(String comment) {
m_Comment = comment;
mComment = comment;
}

/**
@@ -162,7 +184,7 @@ private void checkOptions(Commandline cmd) {
* @return String containing the desired comment method
*/
public String getComment() {
return m_Comment;
return mComment;
}

/**
@@ -171,7 +193,7 @@ private void checkOptions(Commandline cmd) {
* @param pname pathname to be locked
*/
public void setPname(String pname) {
m_Pname = pname;
mPname = pname;
}

/**
@@ -180,7 +202,7 @@ private void checkOptions(Commandline cmd) {
* @return String containing the pathname to be locked
*/
public String getPname() {
return m_Pname;
return mPname;
}

/**
@@ -189,7 +211,17 @@ private void checkOptions(Commandline cmd) {
* @param objselect objects to be locked
*/
public void setObjselect(String objselect) {
m_Objselect = objselect;
mObjselect = objselect;
}

/**
* 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;
}

/**
@@ -198,9 +230,10 @@ private void checkOptions(Commandline cmd) {
* @return String containing the objects to be locked
*/
public String getObjselect() {
return m_Objselect;
return mObjselect;
}


/**
* Get the 'comment' command
*
@@ -242,22 +275,16 @@ private void checkOptions(Commandline cmd) {
}

/**
* Get the 'pname' command
* Return which object/pname is being operated on
*
* @param cmd containing the command line string with or without
* the pname flag and value appended
* @return String containing the object/pname being worked on
*/
private void getObjselectCommand(Commandline cmd) {
if (getObjselect() == null) {
return;
private String getOpType() {

if (getPname() != null) {
return getPname();
} 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_OBJSELECT);
cmd.createArgument().setValue(getPname());
return getObjselect();
}
}

@@ -269,9 +296,5 @@ private void checkOptions(Commandline cmd) {
* -pname flag -- pathname to lock
*/
public static final String FLAG_PNAME = "-pname";
/**
* object-selector option -- list of objects to lock
*/
public static final String FLAG_OBJSELECT = "";
}


+ 32
- 21
src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUpdate.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000,2002-2003 The Apache Software Foundation. All rights
* Copyright (c) 2000,2002-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -107,23 +107,29 @@ import org.apache.tools.ant.types.Commandline;
* 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>
*
* @author Curtis White
*/
public class CCUpdate extends ClearCase {
private boolean m_Graphical = false;
private boolean m_Overwrite = false;
private boolean m_Rename = false;
private boolean m_Ctime = false;
private boolean m_Ptime = false;
private String m_Log = null;
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();
@@ -145,10 +151,14 @@ public class CCUpdate extends ClearCase {
checkOptions(commandLine);

// For debugging
System.out.println(commandLine.toString());
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)) {
if (Execute.isFailure(result) && getFailOnErr()) {
String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, getLocation());
}
@@ -200,7 +210,7 @@ public class CCUpdate extends ClearCase {
* @param graphical the status to set the flag to
*/
public void setGraphical(boolean graphical) {
m_Graphical = graphical;
mGraphical = graphical;
}

/**
@@ -209,7 +219,7 @@ public class CCUpdate extends ClearCase {
* @return boolean containing status of graphical flag
*/
public boolean getGraphical() {
return m_Graphical;
return mGraphical;
}

/**
@@ -218,7 +228,7 @@ public class CCUpdate extends ClearCase {
* @param ow the status to set the flag to
*/
public void setOverwrite(boolean ow) {
m_Overwrite = ow;
mOverwrite = ow;
}

/**
@@ -227,7 +237,7 @@ public class CCUpdate extends ClearCase {
* @return boolean containing status of overwrite flag
*/
public boolean getOverwrite() {
return m_Overwrite;
return mOverwrite;
}

/**
@@ -236,7 +246,7 @@ public class CCUpdate extends ClearCase {
* @param ren the status to set the flag to
*/
public void setRename(boolean ren) {
m_Rename = ren;
mRename = ren;
}

/**
@@ -245,7 +255,7 @@ public class CCUpdate extends ClearCase {
* @return boolean containing status of rename flag
*/
public boolean getRename() {
return m_Rename;
return mRename;
}

/**
@@ -255,7 +265,7 @@ public class CCUpdate extends ClearCase {
* @param ct the status to set the flag to
*/
public void setCurrentTime(boolean ct) {
m_Ctime = ct;
mCtime = ct;
}

/**
@@ -264,7 +274,7 @@ public class CCUpdate extends ClearCase {
* @return boolean containing status of current time flag
*/
public boolean getCurrentTime() {
return m_Ctime;
return mCtime;
}

/**
@@ -274,7 +284,7 @@ public class CCUpdate extends ClearCase {
* @param pt the status to set the flag to
*/
public void setPreserveTime(boolean pt) {
m_Ptime = pt;
mPtime = pt;
}

/**
@@ -283,7 +293,7 @@ public class CCUpdate extends ClearCase {
* @return boolean containing status of preserve time flag
*/
public boolean getPreserveTime() {
return m_Ptime;
return mPtime;
}

/**
@@ -293,7 +303,7 @@ public class CCUpdate extends ClearCase {
* @param log the path to the log file
*/
public void setLog(String log) {
m_Log = log;
mLog = log;
}

/**
@@ -302,9 +312,10 @@ public class CCUpdate extends ClearCase {
* @return String containing the path to the log file
*/
public String getLog() {
return m_Log;
return mLog;
}


/**
* Get the 'log' command
*


+ 85
- 14
src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* Copyright (c) 2000-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -54,9 +54,11 @@

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;
@@ -79,17 +81,18 @@ import org.apache.tools.ant.types.Commandline;
* @author Curtis White (Extended by Sean P. Kane)
*/
public abstract class ClearCase extends Task {
private String m_ClearToolDir = "";
private String m_viewPath = null;
private String m_objSelect = null;

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) {
m_ClearToolDir = getProject().translatePath(dir);
mClearToolDir = getProject().translatePath(dir);
}

/**
@@ -98,7 +101,7 @@ public abstract class ClearCase extends Task {
* @return String containing path to the executable
*/
protected final String getClearToolCommand() {
String toReturn = m_ClearToolDir;
String toReturn = mClearToolDir;
if (!toReturn.equals("") && !toReturn.endsWith("/")) {
toReturn += "/";
}
@@ -114,16 +117,25 @@ public abstract class ClearCase extends Task {
* @param viewPath Path to the view directory or file
*/
public final void setViewPath(String viewPath) {
m_viewPath = viewPath;
mviewPath = viewPath;
}

/**
* Get the path to the item in a clearcase view
*
* @return m_viewPath
* @return mviewPath
*/
public String getViewPath() {
return m_viewPath;
return mviewPath;
}

/**
* Get the basename path of the item in a clearcase view
*
* @return basename
*/
public String getViewPathBasename() {
return (new File(mviewPath)).getName();
}

/**
@@ -132,18 +144,23 @@ public abstract class ClearCase extends Task {
* @param objSelect object to operate on
*/
public final void setObjSelect(String objSelect) {
m_objSelect = objSelect;
mobjSelect = objSelect;
}

/**
* Get the object to operate on
*
* @return m_objSelect
* @return mobjSelect
*/
public String getObjSelect() {
return m_objSelect;
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();
@@ -158,11 +175,49 @@ public abstract class ClearCase extends Task {
}
}

/**
* 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++;
Project aProj = getProject();
ExecTask exe = (ExecTask) aProj.createTask("exec");
Commandline.Argument arg = exe.createArg();

exe.setExecutable(cmdline.getExecutable());
arg.setLine(cmdline.toString(cmdline.getArguments()));
exe.setOutputproperty(outV);
exe.execute();
// System.out.println( "runS: " + outV + " : " + aProj.getProperty( outV ));

return aProj.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
*/
@@ -203,6 +258,22 @@ public abstract class ClearCase extends Task {
* 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";

}


Loading…
Cancel
Save