Browse Source

Add support for filesets to ccmcheckout

PR:	14857
Submitted By: 	Benoit Moussaud


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273948 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 22 years ago
parent
commit
98a9c95a45
3 changed files with 88 additions and 15 deletions
  1. +1
    -1
      WHATSNEW
  2. +26
    -6
      docs/manual/OptionalTasks/ccm.html
  3. +61
    -8
      src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheck.java

+ 1
- 1
WHATSNEW View File

@@ -175,7 +175,7 @@ Other changes:


* Shipped XML parser is now Xerces 2.3.0 * Shipped XML parser is now Xerces 2.3.0


* <style> has a new attribute reuseloadedstylesheet to work around a
* <style> has a new attribute reloadstylesheet to work around a
bug in widespread Xalan versions. bug in widespread Xalan versions.


* <tarfileset> has a new dirmode attribute to specify the permissions * <tarfileset> has a new dirmode attribute to specify the permissions


+ 26
- 6
docs/manual/OptionalTasks/ccm.html View File

@@ -9,17 +9,18 @@


<h1>Continuus Support</h1> <h1>Continuus Support</h1>
<ul> <ul>
<li><a href="#cccheckin">CCMCheckin</a></li>
<li><a href="#cccheckout">CCMCheckout</a></li>
<li><a href="#ccmheckin">CCMCheckin</a></li>
<li><a href="#ccmcheckout">CCMCheckout</a></li>
<li><a href="#ccmcheckintask">CCMCheckinTask</a></li> <li><a href="#ccmcheckintask">CCMCheckinTask</a></li>
<li><a href="#ccmreconfigure">CCMReconfigure</a></li> <li><a href="#ccmreconfigure">CCMReconfigure</a></li>
<li><a href="#ccmcreatetask">CCMCreateTask</a></li> <li><a href="#ccmcreatetask">CCMCreateTask</a></li>
</ul> </ul>


<p>These ant tasks are wrappers around Continuus Source Manager. They have been tested <p>These ant tasks are wrappers around Continuus Source Manager. They have been tested
with version 5.1 on Windows 2000, but should work on other platforms with ccm installed.</p>
agains versions 5.1/6.2 on Windows 2000, but should work on other platforms with ccm installed.</p>
<p>author: <a href="mailto:benoit.moussaud@criltelecom.com">Benoit Mousaud (benoit.moussaud@criltelecom.com) </a></p>
<hr> <hr>
<h2><a name="cccheckin">CCMCheckin</a></h2>
<h2><a name="ccmheckin">CCMCheckin</a></h2>
<h3>Description</h3> <h3>Description</h3>
Task to checkin a file Task to checkin a file
<h3>Parameters</h3> <h3>Parameters</h3>
@@ -60,7 +61,7 @@ Task to checkin a file
Comment attribute <i>mycomment</i> is added as a task comment. The task Comment attribute <i>mycomment</i> is added as a task comment. The task
used is the one set as the default.</p> used is the one set as the default.</p>
<hr> <hr>
<h2><a name="cccheckout">CCMCheckout</a></h2>
<h2><a name="ccmheckout">CCMCheckout</a></h2>
<h3>Description</h3> <h3>Description</h3>
Task to perform a Checkout command to Continuus Task to perform a Checkout command to Continuus
<h3>Parameters</h3> <h3>Parameters</h3>
@@ -73,7 +74,11 @@ Task to perform a Checkout command to Continuus
<tr> <tr>
<td>file</td> <td>file</td>
<td>Path to the file that the command will operate on</td> <td>Path to the file that the command will operate on</td>
<td>Yes</td>
<td rowspan=2">Yes (file|fileset)</td>
</tr>
<tr>
<td>fileset</td>
<td>filset containing the file to be checked out</td>
</tr> </tr>
<tr> <tr>
<td>comment</td> <td>comment</td>
@@ -101,6 +106,21 @@ Task to perform a Checkout command to Continuus
<p>Check out the file <i>c:/wa/com/foo/MyFile.java</i>. <p>Check out the file <i>c:/wa/com/foo/MyFile.java</i>.
Comment attribute <i>mycomment</i> is added as a task comment Comment attribute <i>mycomment</i> is added as a task comment
The used task is the one set as the default.</p> The used task is the one set as the default.</p>
<blockquote>
<pre>&lt;ccmcheckout comment=&quot;mycomment&quot;&gt;
&lt;fileset dir=&quot;lib&quot; &gt;
&lt;include name=&quot;**/*.jar&quot; /&gt;
&lt;/fileset&gt;
&lt;/ccmcheckout &gt;
</pre>
</blockquote>

<p>Check out all the files in the <i>lib</i> directory having the <i>.jar</i> extension.
Comment attribute <i>mycomment</i> is added as a task comment
The used task is the one set as the default.</p>



<hr> <hr>
<h2><a name="ccmcheckintask">CCMCheckinTask</a></h2> <h2><a name="ccmcheckintask">CCMCheckinTask</a></h2>
<h3>Description</h3> <h3>Description</h3>


+ 61
- 8
src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheck.java View File

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


package org.apache.tools.ant.taskdefs.optional.ccm; package org.apache.tools.ant.taskdefs.optional.ccm;



import java.io.File; import java.io.File;
import java.util.Vector;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.FileSet;



/** /**
* Class common to all check commands (checkout, checkin,checkin default task); * Class common to all check commands (checkout, checkin,checkin default task);
@@ -69,6 +74,8 @@ public class CCMCheck extends Continuus {
private File file = null; private File file = null;
private String comment = null; private String comment = null;
private String task = null; private String task = null;
protected Vector filesets = new Vector();


public CCMCheck() { public CCMCheck() {
super(); super();
@@ -87,6 +94,7 @@ public class CCMCheck extends Continuus {
* @param v Value to assign to file. * @param v Value to assign to file.
*/ */
public void setFile(File v) { public void setFile(File v) {
log("working file "+v, Project.MSG_VERBOSE);
this.file = v; this.file = v;
} }


@@ -125,6 +133,14 @@ public class CCMCheck extends Continuus {
} }




/**
* Adds a set of files to copy.
*/
public void addFileset(FileSet set) {
filesets.addElement(set);
}


/** /**
* Executes the task. * Executes the task.
* <p> * <p>
@@ -133,18 +149,55 @@ public class CCMCheck extends Continuus {
* </p> * </p>
*/ */
public void execute() throws BuildException { public void execute() throws BuildException {

if (file == null && filesets.size() == 0) {
throw new BuildException(
"Specify at least one source - a file or a fileset.");
}

if (file != null && file.exists() && file.isDirectory()) {
throw new BuildException("CCMCheck cannot be generated for directories");
}
if (file != null && filesets.size() > 0) {
throw new BuildException("Choose between file and fileset !");
}

if ( getFile() !=null ) {
doit();
return ;
}
int sizeofFileSet = filesets.size();
for (int i = 0; i < sizeofFileSet; i++) {
FileSet fs = (FileSet) filesets.elementAt(i);
DirectoryScanner ds = fs.getDirectoryScanner(project);
String[] srcFiles = ds.getIncludedFiles();
for (int j = 0; j < srcFiles.length; j++) {
File src = new File(fs.getDir(project), srcFiles[j]);
setFile(src);
doit();
}
}
}
/**
* check the file given by getFile().
*/
private void doit()
{
Commandline commandLine = new Commandline(); Commandline commandLine = new Commandline();
int result = 0;


// build the command line from what we got the format is // build the command line from what we got the format is
// ccm co /t .. files // ccm co /t .. files
// as specified in the CLEARTOOL.EXE help
// as specified in the CCM.EXE help

commandLine.setExecutable(getCcmCommand()); commandLine.setExecutable(getCcmCommand());
commandLine.createArgument().setValue(getCcmAction()); commandLine.createArgument().setValue(getCcmAction());

checkOptions(commandLine); checkOptions(commandLine);

result = run(commandLine);
int result = run(commandLine);
if (result != 0) { if (result != 0) {
String msg = "Failed executing: " + commandLine.toString(); String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg, getLocation()); throw new BuildException(msg, getLocation());
@@ -164,11 +217,11 @@ public class CCMCheck extends Continuus {
if (getTask() != null) { if (getTask() != null) {
cmd.createArgument().setValue(FLAG_TASK); cmd.createArgument().setValue(FLAG_TASK);
cmd.createArgument().setValue(getTask()); cmd.createArgument().setValue(getTask());
} // end of if ()
}


if (getFile() != null) { if (getFile() != null) {
cmd.createArgument().setValue(file.getAbsolutePath()); cmd.createArgument().setValue(file.getAbsolutePath());
} // end of if ()
}
} }


/** /**


Loading…
Cancel
Save