Browse Source

6 New ClearCase Tasks Created

PR: 17408

Submitted by: spkane@genomatica.com (Sean P. Kane)


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274451 13f79535-47bb-0310-9956-ffa450edef68
master
Magesh Umasankar 22 years ago
parent
commit
d07b90cde7
10 changed files with 2865 additions and 54 deletions
  1. +451
    -48
      docs/manual/OptionalTasks/clearcase.html
  2. +2
    -2
      docs/manual/tasksoverview.html
  3. +6
    -0
      src/main/org/apache/tools/ant/taskdefs/defaults.properties
  4. +389
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCLock.java
  5. +396
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMkbl.java
  6. +433
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMklabel.java
  7. +465
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCMklbtype.java
  8. +403
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCRmtype.java
  9. +273
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/clearcase/CCUnlock.java
  10. +47
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java

+ 451
- 48
docs/manual/OptionalTasks/clearcase.html View File

@@ -6,19 +6,45 @@
</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>

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

<h1>ClearCase Support</h1>
<h2>Table of Contents</h2>
<ul>
<li><a href="#cccheckin">CCCheckin</a></li>
<li><a href="#cccheckout">CCCheckout</a></li>
<li><a href="#ccuncheckout">CCUnCheckout</a></li>
<li><a href="#ccupdate">CCUpdate</a></li>
<li><A href="#introduction">Introduction</a>
<li><A href="#cccheckin">CCCheckin</a>
<li><A href="#cccheckout">CCCheckout</a>
<li><A href="#ccuncheckout">CCUnCheckout</a>
<li><A href="#ccupdate">CCUpdate</a>
<li><A href="#ccmklbtype">CCMklbtype</a>
<li><A href="#ccmklabel">CCMklabel</a>
<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>

</ul>

<hr>
<h2><a name="introduction">Introduction</a></h2>
<p>Ant provides several optional tasks for working with ClearCase. These tasks correspond to various
ClearCase commands using the Cleartool program. The current tasks avaliable for Ant correspond to only
a few of the significant ClearCase commands.</p>

<p>More tasks can be easily added by deriving from the ClearCase class and then adding
functionality that is specific to that ClearCase command.</p>


<hr>
<h2><a name="cccheckin">CCCheckin</a></h2>
<h3>Description</h3>
Task to perform a Checkin command to ClearCase.
Task to perform a "cleartool checkin" command to ClearCase.
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
@@ -28,7 +54,7 @@ Task to perform a Checkin command to ClearCase.
</tr>
<tr>
<td>viewpath</td>
<td>Path to the ClearCase view file or directory that the command
<td>Path to the ClearCase view file or directory that the command
will operate on</td>
<td>No</td>
</tr>
@@ -39,7 +65,7 @@ Task to perform a Checkin command to ClearCase.
</tr>
<tr>
<td>commentfile</td>
<td>Specify a file containing a comment. Only one of comment or commentfile
<td>Specify a file containing a comment. Only one of comment or commentfile
may be used.</td>
<td>No</td>
</tr>
@@ -60,7 +86,7 @@ Task to perform a Checkin command to ClearCase.
</tr>
<tr>
<td>identical</td>
<td>Allows the file to be checked in even if it is identical
<td>Allows the file to be checked in even if it is identical
to the original</td>
<td>No</td>
</tr>
@@ -68,20 +94,20 @@ Task to perform a Checkin command to ClearCase.
<h3>Examples</h3>
<blockquote>
<pre>
&lt;cccheckin viewpath=&quot;c:/views/viewdir/afile&quot;
commentfile=&quot;acomment.txt&quot;
nowarn=&quot;true&quot;
identical=&quot;true&quot;/&gt;
&lt;cccheckin viewpath="c:/views/viewdir/afile"
commentfile="acomment.txt"
nowarn="true"
identical="true"/&gt;
</pre>
</blockquote>
<p>Does a ClearCase <i>checkin</i> on the file <i>c:/views/viewdir/afile</i>.
<p>Does a ClearCase <i>checkin</i> on the file <i>c:/views/viewdir/afile</i>.
Comment text from the file <i>acomment.txt</i> is added to ClearCase as a comment.
All warning messages are suppressed. The file is checked in even if it is
<i>identical</i> to the original.</p>
<hr>
<h2><a name="cccheckout">CCCheckout</a></h2>
<h3>Description</h3>
Task to perform a Checkout command to ClearCase.
Task to perform a "cleartool checkout" command to ClearCase.
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
@@ -91,7 +117,7 @@ Task to perform a Checkout command to ClearCase.
</tr>
<tr>
<td>viewpath</td>
<td>Path to the ClearCase view file or directory that the command
<td>Path to the ClearCase view file or directory that the command
will operate on</td>
<td>No</td>
</tr>
@@ -107,7 +133,7 @@ Task to perform a Checkout command to ClearCase.
</tr>
<tr>
<td>nodata</td>
<td>Checks out the file but does not create an editable file
<td>Checks out the file but does not create an editable file
containing its data</td>
<td>No</td>
</tr>
@@ -133,7 +159,7 @@ Task to perform a Checkout command to ClearCase.
</tr>
<tr>
<td>commentfile</td>
<td>Specify a file containing a comment. Only one of comment or
<td>Specify a file containing a comment. Only one of comment or
commentfile may be used.</td>
<td>No</td>
</tr>
@@ -141,16 +167,16 @@ Task to perform a Checkout command to ClearCase.
<h3>Examples</h3>
<blockquote>
<pre>
&lt;cccheckout viewpath=&quot;c:/views/viewdir/afile&quot;
reserved=&quot;true&quot;
branch=&quot;abranch&quot;
nowarn=&quot;true&quot;
comment=&quot;Some comment text&quot;/&gt;
&lt;cccheckout viewpath="c:/views/viewdir/afile"
reserved="true"
branch="abranch"
nowarn="true"
comment="Some comment text"/&gt;
</pre>
</blockquote>
<p>Does a ClearCase <i>checkout</i> on the file <i>c:/views/viewdir/afile</i>.
It is checked out as <i>reserved</i> on branch called <i>abranch</i>. All
warning messages are suppressed. A <i>Some comment text</i> is added to
<p>Does a ClearCase <i>checkout</i> on the file <i>c:/views/viewdir/afile</i>.
It is checked out as <i>reserved</i> on branch called <i>abranch</i>. All
warning messages are suppressed. A <i>Some comment text</i> is added to
ClearCase as a comment.</p>
<hr>
<h2><a name="ccuncheckout">CCUnCheckout</a></h2>
@@ -165,13 +191,13 @@ Task to perform a UnCheckout command to ClearCase.
</tr>
<tr>
<td>viewpath</td>
<td>Path to the ClearCase view file or directory that the command
<td>Path to the ClearCase view file or directory that the command
will operate on</td>
<td>No</td>
</tr>
<tr>
<td>keepcopy</td>
<td>Specifies whether to keep a copy of the file with a .keep
<td>Specifies whether to keep a copy of the file with a .keep
extension or not</td>
<td>No</td>
</tr>
@@ -179,16 +205,16 @@ Task to perform a UnCheckout command to ClearCase.
<h3>Examples</h3>
<blockquote>
<pre>
&lt;ccuncheckout viewpath=&quot;c:/views/viewdir/afile&quot;
keepcopy=&quot;true&quot;/&gt;
&lt;ccuncheckout viewpath="c:/views/viewdir/afile"
keepcopy="true"/&gt;
</pre>
</blockquote>
<p>Does a ClearCase <i>uncheckout</i> on the file <i>c:/views/viewdir/afile</i>.
<p>Does a ClearCase <i>uncheckout</i> on the file <i>c:/views/viewdir/afile</i>.
A copy of the file called <i>c:/views/viewdir/afile.keep</i> is kept.</p>
<hr>
<h2><a name="ccupdate">CCUpdate</a></h2>
<h3>Description</h3>
Task to perform an Update command to ClearCase.
Task to perform an "cleartool update" command to ClearCase.
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
@@ -198,7 +224,7 @@ Task to perform an Update command to ClearCase.
</tr>
<tr>
<td>viewpath</td>
<td>Path to the ClearCase view file or directory that the command
<td>Path to the ClearCase snapshot view file or directory that the command
will operate on</td>
<td>No</td>
</tr>
@@ -224,15 +250,15 @@ Task to perform an Update command to ClearCase.
</tr>
<tr>
<td>currenttime</td>
<td>Specifies that modification time should be written as the
current time. Either currenttime or preservetime can be
<td>Specifies that modification time should be written as the
current time. Either currenttime or preservetime can be
specified.</td>
<td>No</td>
</tr>
<tr>
<td>preservetime</td>
<td>Specifies that modification time should preserved from the
VOB time. Either currenttime or preservetime can be
<td>Specifies that modification time should preserved from the
VOB time. Either currenttime or preservetime can be
specified.</td>
<td>No</td>
</tr>
@@ -240,22 +266,399 @@ Task to perform an Update command to ClearCase.
<h3>Examples</h3>
<blockquote>
<pre>
&lt;ccupdate viewpath=&quot;c:/views/viewdir&quot;
graphical=&quot;false&quot;
log=&quot;log.log&quot;
overwrite=&quot;true&quot;
currenttime=&quot;true&quot;
rename=&quot;false&quot;/&gt;
&lt;ccupdate viewpath="c:/views/viewdir"
graphical="false"
log="log.log"
overwrite="true"
currenttime="true"
rename="false"/&gt;
</pre>
</blockquote>
<p>Does a ClearCase <i>update</i> on the directory <i>c:/views/viewdir</i>.
A graphical dialog will be displayed. The output will be logged to
<i>log.log</i> and it will overwrite any hijacked files. The modified
<p>Does a ClearCase <i>update</i> on the snapshot view directory <i>c:/views/viewdir</i>.
A graphical dialog will be displayed. The output will be logged to
<i>log.log</i> and it will overwrite any hijacked files. The modified
time will be set to the current time.</p>



<hr>
<p align="center">Copyright &copy; 2000-2002 Apache Software Foundation. All rights
Reserved.</p>
</body>
<h2><a name="ccmklbtype">CCMklbtype</a></h2>
<h3>Description</h3>
Task to perform a "mklbtype" command to ClearCase.
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<th>Attribute</th>
<th>Values</th>
<th>Required</th>
</tr>
<tr>
<td>typename</td>
<td>Name of the label type to create</td>
<td>Yes</td>
<tr>
<tr>
<td>vob</td>
<td>Name of the VOB</td>
<td>No</td>
<tr>
<tr>
<td>replace</td>
<td>Replace an existing label definition of the same type</td>
<td>No</td>
<tr>
<tr>
<td>global</td>
<td>Either global or ordinary can be specified, not both. Creates a label type that is global to the VOB or to VOBs that use this VOB</td>
<td>No</td>
<tr>
<tr>
<td>ordinary</td>
<td>Either global or ordinary can be specified, not both. Creates a label type that can be used only in the current VOB. <B>Default</B></td>
<td>No</td>
<tr>
<tr>
<td>pbranch</td>
<td>Allows the label type to be used once per branch in a given element's version tree</td>
<td>No</td>
<tr>
<tr>
<td>shared</td>
<td>Sets the way mastership is checked by ClearCase. See ClearCase documentation for details</td>
<td>No</td>
<tr>
<tr>
<td>comment</td>
<td>Specify a comment. Only one of comment or cfile may be used.</td>
<td>No</td>
<tr>
<tr>
<td>commentfile</td>
<td>Specify a file containing a comment. Only one of comment or cfile may be used.</td>
<td>No</td>
<tr></tr>
</table>

<h3>Examples</h3>
<blockquote>
<pre>
&lt;ccmklbtype typename="VERSION_1"
ordinary="true"
comment="Development version 1"/&gt;
</pre>
</blockquote>
<p>Does a ClearCase <i>mklbtype</i> to create a label type named <i>VERSION_1</i>.
It is created as <i>ordinary</i> so it is available only to the current VOB.
The text <i>Development version 1</i> is added as a comment.</p>


<hr>
<h2><a name="ccmklabel">CCMklabel</a></h2>
<h3>Description</h3>
Task to perform a "mklabel" command to ClearCase.
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<th>Attribute</th>
<th>Values</th>
<th>Required</th>
</tr>
<tr>
<td>typename</td>
<td>Name of the label type</td>
<td>Yes</td>
<tr>
<tr>
<td>viewpath</td>
<td>Path to the ClearCase view file or directory that the command will operate on</td>
<td>No</td>
<tr>
<tr>
<td>replace</td>
<td>Replace a label of the same type on the same branch</td>
<td>No</td>
<tr>
<tr>
<td>recurse</td>
<td>Process each subdirectory under viewpath</td>
<td>No</td>
<tr>
<tr>
<td>version</td>
<td>Identify a specific version to attach the label to</td>
<td>No</td>
<tr>
<tr>
<td>vob</td>
<td>Name of the VOB</td>
<td>No</td>
<tr>
<tr>
<td>comment</td>
<td>Specify a comment. Only one of comment or cfile may be used.</td>
<td>No</td>
<tr>
<tr>
<td>commentfile</td>
<td>Specify a file containing a comment. Only one of comment or cfile may be used.</td>
<td>No</td>
<tr></tr>
</table>

<h3>Examples</h3>
<blockquote>
<pre>
&lt;ccmklabel viewpath="c:/views/viewdir/afile"
comment="Some comment text"
recurse="true"
version="\main\2"
typename="VERSION_1"/&gt;
</pre>
</blockquote>
<p>Does a ClearCase <i>mklabel</i> on the file <i>c:/views/viewdir/afile</i> under
the main branch for version 2 (<i>\main\2</i>). Text <i>Some comment text</i> is added
as a comment. It will <i>recurse</i> all subdirectories.


<hr>
<h2><a name="ccrmtype">CCRmtype</a></h2>
<h3>Description</h3>
Task to perform a "rmtype" command to ClearCase.
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<th>Attribute</th>
<th>Values</th>
<th>Required</th>
</tr>
<tr>
<td>typekind</td>
<td>The kind of type to create. Valid types are:
<table border="0" width="40%">
<tr>
<td width="15%"> </td>
<td><b>attype</b><br>
<b>brtype</b><br>
<b>eltype</b><br>
<b>hltype</b><br>
<b>lbtype</b><br>
<b>trtype</b>
</td>
<td>- <br>
- <br>
- <br>
- <br>
- <br>
-
</td>
<td>attribute type<br>
branch type<br>
element type<br>
hyperlink type<br>
label type<br>
trigger type
</td>
</tr>
</table>
</td>
<td>Yes</td>
<tr>
<tr>
<td>typename</td>
<td>The name of the type to remove</td>
<td>Yes</td>
<tr>
<tr>
<td>ignore</td>
<td>Used with trigger types only. Forces removal of trigger type even if a pre-operation trigger would prevent its removal</td>
<td>No</td>
<tr>
<tr>
<td>rmall</td>
<td>Removes all instances of a type and the type object itself</td>
<td>No</td>
<tr>
<tr>
<td>comment</td>
<td>Specify a comment. Only one of comment or cfile may be used.</td>
<td>No</td>
<tr>
<tr>
<td>commentfile</td>
<td>Specify a file containing a comment. Only one of comment or cfile may be used.</td>
<td>No</td>
<tr></tr>
</table>

<h3>Examples</h3>
<blockquote>
<pre>
&lt;ccrmtype typekind="lbtype"
typename="VERSION_1"
commentfile="acomment.txt"
rmall="true"/&gt;
</pre>
</blockquote>
<p>Does a ClearCase <i>rmtype</i> to remove a label type (<i>lbtype</i>) named <i>VERSION_1</i>.
Comment text from the file <i>acomment.txt</i> is added as a comment. All instances of the type
are removed, including the type object itself.</p>
<hr>

<h2><a name="cclock">CCLock</a></h2>
<h3>Description</h3>
Task to perform a "cleartool lock" command to ClearCase.
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<th>Attribute</th>
<th>Values</th>
<th>Required</th>
</tr>
<tr>
<td>replace</td>
<td>Specifies replacing an existing lock</td>
<td>No</td>
<tr>
<tr>
<td>nusers</td>
<td>Specifies user(s) who can still modify the object</td>
<td>No</td>
<tr>
<tr>
<td>obsolete</td>
<td>Specifies that the object should be marked obsolete</td>
<td>No</td>
<tr>
<tr>
<td>comment</td>
<td>Specifies how to populate comments fields</td>
<td>No</td>
<tr>
<tr>
<td>pname</td>
<td>Specifies the object pathname to be locked.</td>
<td>Yes</td>
<tr>
<td>objselect</td>
<td>Specifies the object(s) to be locked.</td>
<td>Yes</td>
<tr>

</table>
<h3>Examples</h3>
<blockquote>
<pre>
&lt;cclock
objselect="stream:Application_Integration@\MyProject_PVOB"
/&gt;
</pre>
</blockquote>
<p>Does a ClearCase <i>lock</i> on the object <i>stream:Application_Integration@\MyProject_PVOB</i>.</p>
<hr>

<h2><a name="ccunlock">CCUnlock</a></h2>
<h3>Description</h3>
Task to perform a "cleartool unlock" command to ClearCase.
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<th>Attribute</th>
<th>Values</th>
<th>Required</th>
</tr>
<tr>
<td>comment</td>
<td>Specifies how to populate comments fields</td>
<td>No</td>
<tr>
<tr>
<td>pname</td>
<td>Specifies the object pathname to be unlocked.</td>
<td>Yes</td>
<tr>
<td>objselect</td>
<td>Specifies the object(s) to be unlocked.</td>
<td>Yes</td>
<tr>

</table>
<h3>Examples</h3>
<blockquote>
<pre>
&lt;ccunlock
objselect="stream:Application_Integration@\MyProject_PVOB"
/&gt;
</pre>
</blockquote>
<p>Does a ClearCase <i>unlock</i> on the object <i>stream:Application_Integration@\MyProject_PVOB</i>.</p>
<hr>

<h2><a name="ccmkbl">CCMkbl</a></h2>
<h3>Description</h3>
Task to perform a "cleartool mkbl" command to ClearCase.
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<th>Attribute</th>
<th>Values</th>
<th>Required</th>
</tr>
<tr>
<td>comment</td>
<td>Specify a comment. Only one of comment or cfile may be
used.</td>
<td>No</td>
</tr>
<tr>
<td>commentfile</td>
<td>Specify a file containing a comment. Only one of comment or
cfile may be used.</td>
<td>No</td>
</tr>
<tr>
<td>baselinerootname</td>
<td>Specify the name to be associated with the baseline.</td>
<td>Yes</td>
</tr>
<tr>
<td>nowarn</td>
<td>Suppress warning messages</td>
<td>No</td>
<tr>
<tr>
<td>identical</td>
<td>Allows the baseline to be created even if it is identical to the
previous baseline.</td>
<td>No</td>
</tr>
<tr>
<td>full</td>
<td>Creates a full baseline.</td>
<td>No</td>
</tr>
<tr>
<td>nlabel</td>
<td>Allows the baseline to be created without a label.</td>
<td>No</td>
</tr>
</table>
<h3>Examples</h3>
<blockquote>
<pre>
&lt;ccmkbl
baselinerootname="Application_Baseline_AUTO"
identical="yes"
full="no"
viewpath="v:\ApplicationCC"
/&gt;
</pre>
</blockquote>
<p>Does a ClearCase <i>mkbl</i> on the Integration view at <i>v:\ApplicationCC</i>
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
reserved.</p>
</body>
</html>

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

@@ -1085,8 +1085,8 @@ documentation.</p>

<tr valign="top">
<td nowrap><a href="OptionalTasks/clearcase.html">ClearCase</a></td>
<td><p>Tasks to perform the ClearCase <i>cccheckin</i>, <i>cccheckout</i>,
<i>ccuncheckout</i>, and <i>ccupdate</i> commands.</p></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>
</tr>

<tr valign="top">


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

@@ -142,6 +142,12 @@ ccupdate=org.apache.tools.ant.taskdefs.optional.clearcase.CCUpdate
cccheckout=org.apache.tools.ant.taskdefs.optional.clearcase.CCCheckout
cccheckin=org.apache.tools.ant.taskdefs.optional.clearcase.CCCheckin
ccuncheckout=org.apache.tools.ant.taskdefs.optional.clearcase.CCUnCheckout
ccmklbtype=org.apache.tools.ant.taskdefs.optional.clearcase.CCMklbtype
ccmklabel=org.apache.tools.ant.taskdefs.optional.clearcase.CCMklabel
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
sound=org.apache.tools.ant.taskdefs.optional.sound.SoundTask
junitreport=org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator
vsslabel=org.apache.tools.ant.taskdefs.optional.vss.MSVSSLABEL


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

@@ -0,0 +1,389 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 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.types.Commandline;


/**
* TODO:
* comment field doesn't include all options yet
*/



/**
* Performs a ClearCase Lock command.
*
* <p>
* The following attributes are interpretted:
* <table border="1">
* <tr>
* <th>Attribute</th>
* <th>Values</th>
* <th>Required</th>
* </tr>
* <tr>
* <td>replace</td>
* <td>Specifies replacing an existing lock</td>
* <td>No</td>
* <tr>
* <tr>
* <td>nusers</td>
* <td>Specifies user(s) who can still modify the object</td>
* <td>No</td>
* <tr>
* <tr>
* <td>obsolete</td>
* <td>Specifies that the object should be marked obsolete</td>
* <td>No</td>
* <tr>
* <tr>
* <td>comment</td>
* <td>Specifies how to populate comments fields</td>
* <td>No</td>
* <tr>
* <tr>
* <td>pname</td>
* <td>Specifies the object pathname to be locked.</td>
* <td>Yes</td>
* <tr>
* <td>objselect</td>
* <td>Specifies the object(s) to be locked.</td>
* <td>Yes</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;

/**
* Executes the task.
* <p>
* Builds a command line to execute cleartool and then calls Exec's run method
* to execute the command line.
*/
public void execute() throws BuildException {
Commandline commandLine = new Commandline();
Project aProj = getProject();
int result = 0;

// Default the viewpath to basedir if it is not specified
if (getViewPath() == null) {
setViewPath(aProj.getBaseDir().getPath());
}

// build the command line from what we got the format is
// cleartool lock [options...]
// as specified in the CLEARTOOL.EXE help
commandLine.setExecutable(getClearToolCommand());
commandLine.createArgument().setValue(COMMAND_LOCK);

// Check the command line options
checkOptions(commandLine);

// For debugging
System.out.println(commandLine.toString());

result = run(commandLine);
if (result != 0) {
String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, location);
}
}

/**
* Check the command line options.
*/
private void checkOptions(Commandline cmd) {
// ClearCase items
if (getReplace()) {
// -replace
cmd.createArgument().setValue(FLAG_REPLACE);
}
if (getObsolete()) {
// -obsolete
cmd.createArgument().setValue(FLAG_OBSOLETE);
} else {
getNusersCommand(cmd);
}
getCommentCommand(cmd);
getPnameCommand(cmd);
// object selector
cmd.createArgument().setValue(getObjselect());
}

/**
* If true, replace an existing lock.
*
* @param replace the status to set the flag to
*/
public void setReplace(boolean replace) {
m_Replace = replace;
}

/**
* Get replace flag status
*
* @return boolean containing status of replace flag
*/
public boolean getReplace() {
return m_Replace;
}

/**
* If true, mark object as obsolete.
*
* @param obsolete the status to set the flag to
*/
public void setObsolete(boolean obsolete) {
m_Obsolete = obsolete;
}

/**
* Get obsolete flag status
*
* @return boolean containing status of obsolete flag
*/
public boolean getObsolete() {
return m_Obsolete;
}

/**
* Sets the users who may continue to
* edit the object while it is locked.
*
* @param nusers users excluded from lock
*/
public void setNusers(String nusers) {
m_Nusers = nusers;
}

/**
* Get nusers list
*
* @return String containing the list of users excluded from lock
*/
public String getNusers() {
return m_Nusers;
}

/**
* Sets how comments should be written
* for the event record(s)
*
* @param comment comment method to use
*/
public void setComment(String comment) {
m_Comment = comment;
}

/**
* Get comment method
*
* @return String containing the desired comment method
*/
public String getComment() {
return m_Comment;
}

/**
* Sets the pathname to be locked
*
* @param pname pathname to be locked
*/
public void setPname(String pname) {
m_Pname = pname;
}

/**
* Get the pathname to be locked
*
* @return String containing the pathname to be locked
*/
public String getPname() {
return m_Pname;
}

/**
* Sets the object(s) to be locked
*
* @param objselect objects to be locked
*/
public void setObjselect(String objselect) {
m_Objselect = objselect;
}

/**
* Get list of objects to be locked
*
* @return String containing the objects to be locked
*/
public String getObjselect() {
return m_Objselect;
}

/**
* Get the 'nusers' command
*
* @param cmd containing the command line string with or without the nusers flag and value appended
*/
private void getNusersCommand(Commandline cmd) {
if (getNusers() == null) {
return;
} else {
/* Had to make two separate commands here because if a space is
inserted between the flag and the value, it is treated as a
Windows filename with a space and it is enclosed in double
quotes ("). This breaks clearcase.
*/
cmd.createArgument().setValue(FLAG_NUSERS);
cmd.createArgument().setValue(getNusers());
}
}

/**
* Get the 'comment' command
*
* @param cmd containing the command line string with or without the comment flag and value appended
*/
private void getCommentCommand(Commandline cmd) {
if (getComment() == null) {
return;
} else {
/* Had to make two separate commands here because if a space is
inserted between the flag and the value, it is treated as a
Windows filename with a space and it is enclosed in double
quotes ("). This breaks clearcase.
*/
cmd.createArgument().setValue(FLAG_COMMENT);
cmd.createArgument().setValue(getComment());
}
}

/**
* Get the 'pname' command
*
* @param cmd containing the command line string with or without the pname flag and value appended
*/
private void getPnameCommand(Commandline cmd) {
if (getPname() == null) {
return;
} else {
/* Had to make two separate commands here because if a space is
inserted between the flag and the value, it is treated as a
Windows filename with a space and it is enclosed in double
quotes ("). This breaks clearcase.
*/
cmd.createArgument().setValue(FLAG_PNAME);
cmd.createArgument().setValue(getPname());
}
}

/**
* Get the 'pname' command
*
* @param cmd containing the command line string with or without the pname flag and value appended
*/
private void getObjselectCommand(Commandline cmd) {
if (getObjselect() == null) {
return;
} else {
/* Had to make two separate commands here because if a space is
inserted between the flag and the value, it is treated as a
Windows filename with a space and it is enclosed in double
quotes ("). This breaks clearcase.
*/
cmd.createArgument().setValue(FLAG_OBJSELECT);
cmd.createArgument().setValue(getPname());
}
}

/**
* -replace flag -- replace existing lock on object(s)
*/
public static final String FLAG_REPLACE = "-replace";
/**
* -nusers flag -- list of users to exclude from lock
*/
public static final String FLAG_NUSERS = "-nusers";
/**
* -obsolete flag -- mark locked object as obsolete
*/
public static final String FLAG_OBSOLETE = "-obsolete";
/**
* -comment flag -- method to use for commenting events
*/
public static final String FLAG_COMMENT = "-comment";
/**
* -pname flag -- pathname to lock
*/
public static final String FLAG_PNAME = "-pname";
/**
* object-selector option -- list of objects to lock
*/
public static final String FLAG_OBJSELECT = "";
}


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

@@ -0,0 +1,396 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 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.types.Commandline;
import org.apache.tools.ant.taskdefs.optional.clearcase.*;




/**
* Task to CreateBaseline command to ClearCase.
* <p>
* The following attributes are interpreted:
* <table border="1">
* <tr>
* <th>Attribute</th>
* <th>Values</th>
* <th>Required</th>
* </tr>
* <tr>
* <td>comment</td>
* <td>Specify a comment. Only one of comment or cfile may be
used.</td>
* <td>No</td>
* </tr>
* <tr>
* <td>commentfile</td>
* <td>Specify a file containing a comment. Only one of comment or
cfile may be used.</td>
* <td>No</td>
* </tr>
* <tr>
* <td>baselinerootname</td>
* <td>Specify the name to be associated with the baseline.</td>
* <td>Yes</td>
* </tr>
* <tr>
* <td>nowarn</td>
* <td>Suppress warning messages</td>
* <td>No</td>
* <tr>
* <tr>
* <td>identical</td>
* <td>Allows the baseline to be created even if it is identical to the
previous baseline.</td>
* <td>No</td>
* </tr>
* <tr>
* <td>full</td>
* <td>Creates a full baseline.</td>
* <td>No</td>
* </tr>
* <tr>
* <td>nlabel</td>
* <td>Allows the baseline to be created without a label.</td>
* <td>No</td>
* </tr>
* </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;


/**
* Executes the task.
* <p>
* Builds a command line to execute cleartool and then calls Exec's run method
* to execute the command line.
*/
public void execute() throws BuildException {
Commandline commandLine = new Commandline();
Project aProj = getProject();
int result = 0;

// Default the viewpath to basedir if it is not specified
if (getViewPath() == null) {
setViewPath(aProj.getBaseDir().getPath());
}

// build the command line from what we got. the format is
// cleartool checkin [options...] [viewpath ...]
// as specified in the CLEARTOOL.EXE help
commandLine.setExecutable(getClearToolCommand());
commandLine.createArgument().setValue(COMMAND_MKBL);

checkOptions(commandLine);

result = run(commandLine);
if (result != 0) {
String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, location);
}
}


/**
* Check the command line options.
*/
private void checkOptions(Commandline cmd) {
if (getComment() != null) {
// -c
getCommentCommand(cmd);
} else {
if (getCommentFile() != null) {
// -cfile
getCommentFileCommand(cmd);
} else {
cmd.createArgument().setValue(FLAG_NOCOMMENT);
}
}

if (getIdentical()) {
// -identical
cmd.createArgument().setValue(FLAG_IDENTICAL);
}

if (getFull()) {
// -full
cmd.createArgument().setValue(FLAG_FULL);
} else {
// -incremental
cmd.createArgument().setValue(FLAG_INCREMENTAL);
}

if (getNlabel()) {
// -nlabel
cmd.createArgument().setValue(FLAG_NLABEL);
}

// baseline_root_name
cmd.createArgument().setValue(getBaselineRootName());

}


/**
* Set comment string
*
* @param comment the comment string
*/
public void setComment(String comment) {
m_Comment = comment;
}

/**
* Get comment string
*
* @return String containing the comment
*/
public String getComment() {
return m_Comment;
}

/**
* Set comment file
*
* @param cfile the path to the comment file
*/
public void setCommentFile(String cfile) {
m_Cfile = cfile;
}

/**
* Get comment file
*
* @return String containing the path to the comment file
*/
public String getCommentFile() {
return m_Cfile;
}

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

/**
* Get baseline_root_name
*
* @return String containing the name of the baseline
*/
public String getBaselineRootName() {
return m_BaselineRootName;
}

/**

/**
* Set the nowarn flag
*
* @param nwarn the status to set the flag to
*/
public void setNoWarn(boolean nwarn) {
m_Nwarn = nwarn;
}

/**
* Get nowarn flag status
*
* @return boolean containing status of nwarn flag
*/
public boolean getNoWarn() {
return m_Nwarn;
}

/**
* Set the identical flag
*
* @param identical the status to set the flag to
*/
public void setIdentical(boolean identical) {
m_Identical = identical;
}

/**
* Get identical flag status
*
* @return boolean containing status of identical flag
*/
public boolean getIdentical() {
return m_Identical;
}

/**
* Set the full flag
*
* @param full the status to set the flag to
*/
public void setFull(boolean full) {
m_Full = full;
}

/**
* Get full flag status
*
* @return boolean containing status of full flag
*/
public boolean getFull() {
return m_Full;
}

/**
* Set the nlabel flag
*
* @param nlabel the status to set the flag to
*/
public void setNlabel(boolean nlabel) {
m_Nlabel = nlabel;
}

/**
* Get nlabel status
*
* @return boolean containing status of nlabel flag
*/
public boolean getNlabel() {
return m_Nlabel;
}

/**
* 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 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
*
* @return the 'commentfile' command if the attribute was specified, otherwise an empty string
*
* @param CommandLine containing the command line string with or without the commentfile flag and file appended
*/
private void getCommentFileCommand(Commandline cmd) {
if (getCommentFile() != null) {
/* Had to make two separate commands here because if a space is
inserted between the flag and the value, it is treated as a
Windows filename with a space and it is enclosed in double
quotes ("). This breaks clearcase.
*/
cmd.createArgument().setValue(FLAG_COMMENTFILE);
cmd.createArgument().setValue(getCommentFile());
}
}


/**
* -c flag -- comment to attach to the file
*/
public static final String FLAG_COMMENT = "-c";
/**
* -cfile flag -- file containing a comment to attach to the file
*/
public static final String FLAG_COMMENTFILE = "-cfile";
/**
* -nc flag -- no comment is specified
*/
public static final String FLAG_NOCOMMENT = "-nc";
/**
* -identical flag -- allows the file to be checked in even if it is identical to the original
*/
public static final String FLAG_IDENTICAL = "-identical";
/**
* -incremental flag -- baseline to be created is incremental
*/
public static final String FLAG_INCREMENTAL = "-incremental";
/**
* -full flag -- baseline to be created is full
*/
public static final String FLAG_FULL = "-full";
/**
* -nlabel -- baseline to be created without a label
*/
public static final String FLAG_NLABEL = "-nlabel";


}

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

@@ -0,0 +1,433 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 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.*;
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.Path;

import java.io.File;

/**
* Task to perform mklabel command to ClearCase.
* <p>
* The following attributes are interpreted:
* <table border="1">
* <tr>
* <th>Attribute</th>
* <th>Values</th>
* <th>Required</th>
* </tr>
* <tr>
* <td>viewpath</td>
* <td>Path to the ClearCase view file or directory that the command will operate on</td>
* <td>No</td>
* <tr>
* <tr>
* <td>replace</td>
* <td>Replace a label of the same type on the same branch</td>
* <td>No</td>
* <tr>
* <tr>
* <td>recurse</td>
* <td>Process each subdirectory under viewpath</td>
* <td>No</td>
* <tr>
* <tr>
* <td>version</td>
* <td>Identify a specific version to attach the label to</td>
* <td>No</td>
* <tr>
* <tr>
* <td>typename</td>
* <td>Name of the label type</td>
* <td>Yes</td>
* <tr>
* <tr>
* <td>vob</td>
* <td>Name of the VOB</td>
* <td>No</td>
* <tr>
* <tr>
* <td>comment</td>
* <td>Specify a comment. Only one of comment or cfile may be used.</td>
* <td>No</td>
* <tr>
* <tr>
* <td>commentfile</td>
* <td>Specify a file containing a comment. Only one of comment or cfile may be used.</td>
* <td>No</td>
* <tr>
* </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;

/**
* Executes the task.
* <p>
* Builds a command line to execute cleartool and then calls Exec's run method
* to execute the command line.
*/
public void execute() throws BuildException {
Commandline commandLine = new Commandline();
Project aProj = getProject();
int result = 0;

// Check for required attributes
if (getTypeName() == null) {
throw new BuildException("Required attribute TypeName not specified");
}

// Default the viewpath to basedir if it is not specified
if (getViewPath() == null) {
setViewPath(aProj.getBaseDir().getPath());
}

// build the command line from what we got. the format is
// cleartool mklabel [options...] [viewpath ...]
// as specified in the CLEARTOOL help
commandLine.setExecutable(getClearToolCommand());
commandLine.createArgument().setValue(COMMAND_MKLABEL);

checkOptions(commandLine);

result = run(commandLine);
if ( result != 0 ) {
String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, location);
}
}


/**
* Check the command line options.
*/
private void checkOptions(Commandline cmd) {
if (getReplace()) {
// -replace
cmd.createArgument().setValue(FLAG_REPLACE);
}

if (getRecurse()) {
// -recurse
cmd.createArgument().setValue(FLAG_RECURSE);
}

if (getVersion() != null) {
// -version
getVersionCommand(cmd);
}

if (getComment() != null) {
// -c
getCommentCommand(cmd);
} else {
if (getCommentFile() != null) {
// -cfile
getCommentFileCommand(cmd);
} else {
cmd.createArgument().setValue(FLAG_NOCOMMENT);
}
}

if (getTypeName() != null) {
// type
getTypeCommand(cmd);
}

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


/**
* Set the replace flag
*
* @param replace the status to set the flag to
*/
public void setReplace(boolean repl) {
m_Replace = repl;
}

/**
* Get replace flag status
*
* @return boolean containing status of replace flag
*/
public boolean getReplace() {
return m_Replace;
}

/**
* Set recurse flag
*
* @param recurse the status to set the flag to
*/
public void setRecurse(boolean recurse) {
m_Recurse = recurse;
}

/**
* Get recurse flag status
*
* @return boolean containing status of recurse flag
*/
public boolean getRecurse() {
return m_Recurse;
}

/**
* Set the version flag
*
* @param version the status to set the flag to
*/
public void setVersion(String ver) {
m_Version = ver;
}

/**
* Get version flag status
*
* @return boolean containing status of version flag
*/
public String getVersion() {
return m_Version;
}

/**
* Set comment string
*
* @param comment the comment string
*/
public void setComment(String comment) {
m_Comment = comment;
}

/**
* Get comment string
*
* @return String containing the comment
*/
public String getComment() {
return m_Comment;
}

/**
* Set comment file
*
* @param cfile the path to the comment file
*/
public void setCommentFile(String cfile) {
m_Cfile = cfile;
}

/**
* Get comment file
*
* @return String containing the path to the comment file
*/
public String getCommentFile() {
return m_Cfile;
}

/**
* Set the type-name
*
* @param tn the type name
*/
public void setTypeName(String tn) {
m_TypeName = tn;
}

/**
* Get type-name
*
* @return String containing type name
*/
public String getTypeName() {
return m_TypeName;
}

/**
* Set the VOB name
*
* @param vob the VOB name
*/
public void setVOB(String vob) {
m_VOB = vob;
}

/**
* Get VOB name
*
* @return String containing VOB name
*/
public String getVOB() {
return m_VOB;
}

/**
* Get the 'version' command
*
* @return the 'version' command if the attribute was specified, otherwise an empty string
*
* @param 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
*
* @return the 'comment' command if the attribute was specified, otherwise an empty string
*
* @param CommandLine 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
*
* @return the 'commentfile' command if the attribute was specified, otherwise an empty string
*
* @param CommandLine containing the command line string with or without the commentfile flag and file appended
*/
private void getCommentFileCommand(Commandline cmd) {
if (getCommentFile() != null) {
/* Had to make two separate commands here because if a space is
inserted between the flag and the value, it is treated as a
Windows filename with a space and it is enclosed in double
quotes ("). This breaks clearcase.
*/
cmd.createArgument().setValue(FLAG_COMMENTFILE);
cmd.createArgument().setValue(getCommentFile());
}
}

/**
* 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 without the type-name
*/
private void getTypeCommand(Commandline cmd) {
String typenm = null;

if (getTypeName() != null) {
typenm = getTypeName();
if (getVOB() != null) {
typenm += "@" + getVOB();
}
cmd.createArgument().setValue(typenm);
}
}


/**
* -replace flag -- replace another label of the same type
*/
public static final String FLAG_REPLACE = "-replace";
/**
* -recurse flag -- process all subdirectories
*/
public static final String FLAG_RECURSE = "-recurse";
/**
* -version flag -- attach label to specified version
*/
public static final String FLAG_VERSION = "-version";
/**
* -c flag -- comment to attach to the file
*/
public static final String FLAG_COMMENT = "-c";
/**
* -cfile flag -- file containing a comment to attach to the file
*/
public static final String FLAG_COMMENTFILE = "-cfile";
/**
* -nc flag -- no comment is specified
*/
public static final String FLAG_NOCOMMENT = "-nc";

}


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

@@ -0,0 +1,465 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 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.*;
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.Path;

import java.io.File;

/**
* Task to perform mklbtype command to ClearCase.
* <p>
* The following attributes are interpreted:
* <table border="1">
* <tr>
* <th>Attribute</th>
* <th>Values</th>
* <th>Required</th>
* </tr>
* <tr>
* <td>typename</td>
* <td>Name of the label type to create</td>
* <td>Yes</td>
* <tr>
* <tr>
* <td>vob</td>
* <td>Name of the VOB</td>
* <td>No</td>
* <tr>
* <tr>
* <td>replace</td>
* <td>Replace an existing label definition of the same type</td>
* <td>No</td>
* <tr>
* <tr>
* <td>global</td>
* <td>Either global or ordinary can be specified, not both. Creates a label type that is global to the VOB or to VOBs that use this VOB</td>
* <td>No</td>
* <tr>
* <tr>
* <td>ordinary</td>
* <td>Either global or ordinary can be specified, not both. Creates a label type that can be used only in the current VOB. <B>Default</B></td>
* <td>No</td>
* <tr>
* <tr>
* <td>pbranch</td>
* <td>Allows the label type to be used once per branch in a given element's version tree</td>
* <td>No</td>
* <tr>
* <tr>
* <td>shared</td>
* <td>Sets the way mastership is checked by ClearCase. See ClearCase documentation for details</td>
* <td>No</td>
* <tr>
* <tr>
* <td>comment</td>
* <td>Specify a comment. Only one of comment or cfile may be used.</td>
* <td>No</td>
* <tr>
* <tr>
* <td>commentfile</td>
* <td>Specify a file containing a comment. Only one of comment or cfile may be used.</td>
* <td>No</td>
* <tr>
* </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;

/**
* Executes the task.
* <p>
* Builds a command line to execute cleartool and then calls Exec's run method
* to execute the command line.
*/
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");
}

// build the command line from what we got. the format is
// cleartool mklbtype [options...] type-selector...
// as specified in the CLEARTOOL help
commandLine.setExecutable(getClearToolCommand());
commandLine.createArgument().setValue(COMMAND_MKLBTYPE);

checkOptions(commandLine);

result = run(commandLine);
if ( result != 0 ) {
String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, location);
}
}


/**
* Check the command line options.
*/
private void checkOptions(Commandline cmd) {
if (getReplace()) {
// -replace
cmd.createArgument().setValue(FLAG_REPLACE);
}

if (getOrdinary()) {
// -ordinary
cmd.createArgument().setValue(FLAG_ORDINARY);
} else {
if (getGlobal()) {
// -global
cmd.createArgument().setValue(FLAG_GLOBAL);
}
}

if (getPbranch()) {
// -pbranch
cmd.createArgument().setValue(FLAG_PBRANCH);
}

if (getShared()) {
// -shared
cmd.createArgument().setValue(FLAG_SHARED);
}

if (getComment() != null) {
// -c
getCommentCommand(cmd);
} else {
if (getCommentFile() != null) {
// -cfile
getCommentFileCommand(cmd);
} else {
cmd.createArgument().setValue(FLAG_NOCOMMENT);
}
}

// type-name@vob
cmd.createArgument().setValue(getTypeSpecifier());
}


/**
* Set type-name string
*
* @param tn the type-name string
*/
public void setTypeName(String tn) {
m_TypeName = tn;
}

/**
* Get type-name string
*
* @return String containing the type-name
*/
public String getTypeName() {
return m_TypeName;
}

/**
* Set the VOB name
*
* @param vob the VOB name
*/
public void setVOB(String vob) {
m_VOB = vob;
}

/**
* Get VOB name
*
* @return String containing VOB name
*/
public String getVOB() {
return m_VOB;
}

/**
* Set the replace flag
*
* @param repl the status to set the flag to
*/
public void setReplace(boolean repl) {
m_Replace = repl;
}

/**
* Get replace flag status
*
* @return boolean containing status of replace flag
*/
public boolean getReplace() {
return m_Replace;
}

/**
* Set the global flag
*
* @param glob the status to set the flag to
*/
public void setGlobal(boolean glob) {
m_Global = glob;
}

/**
* Get global flag status
*
* @return boolean containing status of global flag
*/
public boolean getGlobal() {
return m_Global;
}

/**
* Set the ordinary flag
*
* @param ordinary the status to set the flag to
*/
public void setOrdinary(boolean ordinary) {
m_Ordinary = ordinary;
}

/**
* Get ordinary flag status
*
* @return boolean containing status of ordinary flag
*/
public boolean getOrdinary() {
return m_Ordinary;
}

/**
* Set the pbranch flag
*
* @param pbranch the status to set the flag to
*/
public void setPbranch(boolean pbranch) {
m_Pbranch = pbranch;
}

/**
* Get pbranch flag status
*
* @return boolean containing status of pbranch flag
*/
public boolean getPbranch() {
return m_Pbranch;
}

/**
* Set the shared flag
*
* @param shared the status to set the flag to
*/
public void setShared(boolean shar) {
m_Shared = shar;
}

/**
* Get shared flag status
*
* @return boolean containing status of shared flag
*/
public boolean getShared() {
return m_Shared;
}

/**
* Set comment string
*
* @param comment the comment string
*/
public void setComment(String comment) {
m_Comment = comment;
}

/**
* Get comment string
*
* @return String containing the comment
*/
public String getComment() {
return m_Comment;
}

/**
* Set comment file
*
* @param cfile the path to the comment file
*/
public void setCommentFile(String cfile) {
m_Cfile = cfile;
}

/**
* Get comment file
*
* @return String containing the path to the comment file
*/
public String getCommentFile() {
return m_Cfile;
}


/**
* 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 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
*
* @return the 'commentfile' command if the attribute was specified, otherwise an empty string
*
* @param CommandLine containing the command line string with or without the commentfile flag and file appended
*/
private void getCommentFileCommand(Commandline cmd) {
if (getCommentFile() != null) {
/* Had to make two separate commands here because if a space is
inserted between the flag and the value, it is treated as a
Windows filename with a space and it is enclosed in double
quotes ("). This breaks clearcase.
*/
cmd.createArgument().setValue(FLAG_COMMENTFILE);
cmd.createArgument().setValue(getCommentFile());
}
}

/**
* Get the type-name specifier
*
* @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;

typenm = getTypeName();
if (getVOB() != null) {
typenm += "@" + getVOB();
}

return typenm;
}


/**
* -replace flag -- replace existing label definition of the same type
*/
public static final String FLAG_REPLACE = "-replace";
/**
* -global flag -- creates a label type that is global to the VOB or to VOBs that use this VOB
*/
public static final String FLAG_GLOBAL = "-global";
/**
* -ordinary flag -- creates a label type that can be used only in the current VOB
*/
public static final String FLAG_ORDINARY = "-ordinary";
/**
* -pbranch flag -- allows label type to be used once per branch
*/
public static final String FLAG_PBRANCH = "-pbranch";
/**
* -shared flag -- sets the way mastership is checked by ClearCase
*/
public static final String FLAG_SHARED = "-shared";
/**
* -c flag -- comment to attach to the file
*/
public static final String FLAG_COMMENT = "-c";
/**
* -cfile flag -- file containing a comment to attach to the file
*/
public static final String FLAG_COMMENTFILE = "-cfile";
/**
* -nc flag -- no comment is specified
*/
public static final String FLAG_NOCOMMENT = "-nc";

}


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

@@ -0,0 +1,403 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 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.*;
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.Path;

import java.io.File;

/**
* Task to perform rmtype command to ClearCase.
* <p>
* The following attributes are interpreted:
* <table border="1">
* <tr>
* <th>Attribute</th>
* <th>Values</th>
* <th>Required</th>
* </tr>
* <tr>
* <td>typekind</td>
* <td>The kind of type to create. Valid types are:<br>
* attype attribute type<br>
* brtype branch type<br>
* eltype element type<br>
* hltype hyperlink type<br>
* lbtype label type<br>
* trtype trigger type<br>
* </td>
* <td>Yes</td>
* <tr>
* <tr>
* <td>typename</td>
* <td>The name of the type to remove</td>
* <td>Yes</td>
* <tr>
* <tr>
* <td>vob</td>
* <td>Name of the VOB</td>
* <td>No</td>
* <tr>
* <tr>
* <td>ignore</td>
* <td>Used with trigger types only. Forces removal of trigger type even if a pre-operation trigger would prevent its removal</td>
* <td>No</td>
* <tr>
* <tr>
* <td>rmall</td>
* <td>Removes all instances of a type and the type object itself</td>
* <td>No</td>
* <tr>
* <tr>
* <td>comment</td>
* <td>Specify a comment. Only one of comment or cfile may be used.</td>
* <td>No</td>
* <tr>
* <tr>
* <td>commentfile</td>
* <td>Specify a file containing a comment. Only one of comment or cfile may be used.</td>
* <td>No</td>
* <tr>
* </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;

/**
* Executes the task.
* <p>
* Builds a command line to execute cleartool and then calls Exec's run method
* to execute the command line.
*/
public void execute() throws BuildException {
Commandline commandLine = new Commandline();
Project aProj = getProject();
int result = 0;

// Check for required attributes
if (getTypeKind() == null) {
throw new BuildException("Required attribute TypeKind not specified");
}
if (getTypeName() == null) {
throw new BuildException("Required attribute TypeName not specified");
}

// build the command line from what we got. the format is
// cleartool rmtype [options...] type-selector...
// as specified in the CLEARTOOL help
commandLine.setExecutable(getClearToolCommand());
commandLine.createArgument().setValue(COMMAND_RMTYPE);

checkOptions(commandLine);

result = run(commandLine);
if ( result != 0 ) {
String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, location);
}
}


/**
* Check the command line options.
*/
private void checkOptions(Commandline cmd) {
if (getIgnore()) {
// -ignore
cmd.createArgument().setValue(FLAG_IGNORE);
}
if (getRmAll()) {
// -rmall -force
cmd.createArgument().setValue(FLAG_RMALL);
cmd.createArgument().setValue(FLAG_FORCE);
}
if (getComment() != null) {
// -c
getCommentCommand(cmd);
} else {
if (getCommentFile() != null) {
// -cfile
getCommentFileCommand(cmd);
} else {
cmd.createArgument().setValue(FLAG_NOCOMMENT);
}
}

// type-kind:type-name
cmd.createArgument().setValue(getTypeSpecifier());
}

/**
* Set the ignore flag
*
* @param ignore the status to set the flag to
*/
public void setIgnore(boolean ignore) {
m_Ignore = ignore;
}

/**
* Get ignore flag status
*
* @return boolean containing status of ignore flag
*/
public boolean getIgnore() {
return m_Ignore;
}

/**
* Set rmall flag
*
* @param rmall the status to set the flag to
*/
public void setRmAll(boolean rmall) {
m_Rmall = rmall;
}

/**
* Get rmall flag status
*
* @return boolean containing status of rmall flag
*/
public boolean getRmAll() {
return m_Rmall;
}

/**
* Set comment string
*
* @param comment the comment string
*/
public void setComment(String comment) {
m_Comment = comment;
}

/**
* Get comment string
*
* @return String containing the comment
*/
public String getComment() {
return m_Comment;
}

/**
* Set comment file
*
* @param cfile the path to the comment file
*/
public void setCommentFile(String cfile) {
m_Cfile = cfile;
}

/**
* Get comment file
*
* @return String containing the path to the comment file
*/
public String getCommentFile() {
return m_Cfile;
}

/**
* Set type-kind string
*
* @param tk the type-kind string
*/
public void setTypeKind(String tk) {
m_TypeKind = tk;
}

/**
* Get type-kind string
*
* @return String containing the type-kind
*/
public String getTypeKind() {
return m_TypeKind;
}

/**
* Set type-name string
*
* @param tn the type-name string
*/
public void setTypeName(String tn) {
m_TypeName = tn;
}

/**
* Get type-name string
*
* @return String containing the type-name
*/
public String getTypeName() {
return m_TypeName;
}

/**
* Set the VOB name
*
* @param vob the VOB name
*/
public void setVOB(String vob) {
m_VOB = vob;
}

/**
* Get VOB name
*
* @return String containing VOB name
*/
public String getVOB() {
return m_VOB;
}

/**
* Get the 'type-specifier' string
*
* @return the 'type-kind:type-name@vob' specifier
*
* @param CommandLine containing the command line string
*/
private String getTypeSpecifier() {
String tkind = getTypeKind();
String tname = getTypeName();
String typeSpec = null;

// Return the type-selector
typeSpec = tkind + ":" + tname;
if (getVOB() != null) {
typeSpec += "@" + getVOB();
}
return typeSpec;
}

/**
* Get the 'comment' command
*
* @return the 'comment' command if the attribute was specified, otherwise an empty string
*
* @param CommandLine 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
*
* @return the 'commentfile' command if the attribute was specified, otherwise an empty string
*
* @param CommandLine containing the command line string with or without the commentfile flag and file appended
*/
private void getCommentFileCommand(Commandline cmd) {
if (getCommentFile() != null) {
/* Had to make two separate commands here because if a space is
inserted between the flag and the value, it is treated as a
Windows filename with a space and it is enclosed in double
quotes ("). This breaks clearcase.
*/
cmd.createArgument().setValue(FLAG_COMMENTFILE);
cmd.createArgument().setValue(getCommentFile());
}
}


/**
* -ignore flag -- ignore pre-trigger operations when removing a trigger type
*/
public static final String FLAG_IGNORE = "-ignore";
/**
* -rmall flag -- removes all instances of a type and the type object itself
*/
public static final String FLAG_RMALL = "-rmall";
/**
* -force flag -- suppresses confirmation prompts
*/
public static final String FLAG_FORCE = "-force";
/**
* -c flag -- comment to attach to the file
*/
public static final String FLAG_COMMENT = "-c";
/**
* -cfile flag -- file containing a comment to attach to the file
*/
public static final String FLAG_COMMENTFILE = "-cfile";
/**
* -nc flag -- no comment is specified
*/
public static final String FLAG_NOCOMMENT = "-nc";

}


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

@@ -0,0 +1,273 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 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.types.Commandline;

/**
* TODO:
* comment field doesn't include all options yet
*/


/**
* Performs a ClearCase Unlock command.
*
* <p>
* The following attributes are interpretted:
* <table border="1">
* <tr>
* <th>Attribute</th>
* <th>Values</th>
* <th>Required</th>
* </tr>
* <tr>
* <td>comment</td>
* <td>Specifies how to populate comments fields</td>
* <td>No</td>
* <tr>
* <tr>
* <td>pname</td>
* <td>Specifies the object pathname to be unlocked.</td>
* <td>Yes</td>
* <tr>
* <td>objselect</td>
* <td>Specifies the object(s) to be unlocked.</td>
* <td>Yes</td>
* <tr>
*
* </table>
*
* @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;

/**
* Executes the task.
* <p>
* Builds a command line to execute cleartool and then calls Exec's run method
* to execute the command line.
*/
public void execute() throws BuildException {
Commandline commandLine = new Commandline();
Project aProj = getProject();
int result = 0;

// Default the viewpath to basedir if it is not specified
if (getViewPath() == null) {
setViewPath(aProj.getBaseDir().getPath());
}

// build the command line from what we got the format is
// cleartool lock [options...]
// as specified in the CLEARTOOL.EXE help
commandLine.setExecutable(getClearToolCommand());
commandLine.createArgument().setValue(COMMAND_UNLOCK);

// Check the command line options
checkOptions(commandLine);

// For debugging
System.out.println(commandLine.toString());

result = run(commandLine);
if (result != 0) {
String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, location);
}
}

/**
* Check the command line options.
*/
private void checkOptions(Commandline cmd) {
// ClearCase items
getCommentCommand(cmd);
getPnameCommand(cmd);
// object selector
cmd.createArgument().setValue(getObjselect());
}

/**
* Sets how comments should be written
* for the event record(s)
*
* @param comment comment method to use
*/
public void setComment(String comment) {
m_Comment = comment;
}

/**
* Get comment method
*
* @return String containing the desired comment method
*/
public String getComment() {
return m_Comment;
}

/**
* Sets the pathname to be locked
*
* @param pname pathname to be locked
*/
public void setPname(String pname) {
m_Pname = pname;
}

/**
* Get the pathname to be locked
*
* @return String containing the pathname to be locked
*/
public String getPname() {
return m_Pname;
}

/**
* Sets the object(s) to be locked
*
* @param objselect objects to be locked
*/
public void setObjselect(String objselect) {
m_Objselect = objselect;
}

/**
* Get list of objects to be locked
*
* @return String containing the objects to be locked
*/
public String getObjselect() {
return m_Objselect;
}

/**
* Get the 'comment' command
*
* @param cmd containing the command line string with or without the comment flag and value appended
*/
private void getCommentCommand(Commandline cmd) {
if (getComment() == null) {
return;
} else {
/* Had to make two separate commands here because if a space is
inserted between the flag and the value, it is treated as a
Windows filename with a space and it is enclosed in double
quotes ("). This breaks clearcase.
*/
cmd.createArgument().setValue(FLAG_COMMENT);
cmd.createArgument().setValue(getComment());
}
}

/**
* Get the 'pname' command
*
* @param cmd containing the command line string with or without the pname flag and value appended
*/
private void getPnameCommand(Commandline cmd) {
if (getPname() == null) {
return;
} else {
/* Had to make two separate commands here because if a space is
inserted between the flag and the value, it is treated as a
Windows filename with a space and it is enclosed in double
quotes ("). This breaks clearcase.
*/
cmd.createArgument().setValue(FLAG_PNAME);
cmd.createArgument().setValue(getPname());
}
}

/**
* Get the 'pname' command
*
* @param cmd containing the command line string with or without the pname flag and value appended
*/
private void getObjselectCommand(Commandline cmd) {
if (getObjselect() == null) {
return;
} else {
/* Had to make two separate commands here because if a space is
inserted between the flag and the value, it is treated as a
Windows filename with a space and it is enclosed in double
quotes ("). This breaks clearcase.
*/
cmd.createArgument().setValue(FLAG_OBJSELECT);
cmd.createArgument().setValue(getPname());
}
}

/**
* -comment flag -- method to use for commenting events
*/
public static final String FLAG_COMMENT = "-comment";
/**
* -pname flag -- pathname to lock
*/
public static final String FLAG_PNAME = "-pname";
/**
* object-selector option -- list of objects to lock
*/
public static final String FLAG_OBJSELECT = "";
}


+ 47
- 4
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,2002 The Apache Software Foundation. All rights
* Copyright (c) 2000,2002-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -71,15 +71,17 @@ import org.apache.tools.ant.types.Commandline;
* in the path, * you can override this be specifying the cleartooldir attribute.
* </p>
* <p>
* This class provides set and get methods for the 'viewpath' attribute. It
* also contains constants for the flags that can be passed to cleartool.
* This class provides set and get methods for the 'viewpath' and 'objselect'
* attribute. It also contains constants for the flags that can be passed to
* cleartool.
* </p>
*
* @author Curtis White
* @author Curtis White (Exteneded by Sean P. Kane)
*/
public abstract class ClearCase extends Task {
private String m_ClearToolDir = "";
private String m_viewPath = null;
private String m_objSelect = null;

/**
* Set the directory where the cleartool executable is located.
@@ -124,6 +126,23 @@ public abstract class ClearCase extends Task {
return m_viewPath;
}

/**
* Set the object to operate on.
*
* @param objSelect object to operate on
*/
public final void setObjSelect(String objSelect) {
m_objSelect = objSelect;
}

/**
* Get the object to operate on
*
* @return m_objSelect
*/
public String getObjSelect() {
return m_objSelect;
}

protected int run(Commandline cmd) {
try {
@@ -159,6 +178,30 @@ public abstract class ClearCase extends Task {
* The 'UndoCheckout' command
*/
public static final String COMMAND_UNCHECKOUT = "uncheckout";
/**
* The 'Lock' command
*/
public static final String COMMAND_LOCK = "lock";
/**
* The 'Unlock' command
*/
public static final String COMMAND_UNLOCK = "unlock";
/**
* The 'Mkbl' command
*/
public static final String COMMAND_MKBL = "mkbl";
/**
* The 'Mklabel' command
*/
public static final String COMMAND_MKLABEL = "mklabel";
/**
* The 'Mklbtype' command
*/
public static final String COMMAND_MKLBTYPE = "mklbtype";
/**
* The 'Rmtype' command
*/
public static final String COMMAND_RMTYPE = "rmtype";

}


Loading…
Cancel
Save