Browse Source

Added support for specifying CVS_RSH in ant CVS task.

Submitted by: john.giacomoni@colorado.edu


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269957 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 23 years ago
parent
commit
d5e9b4accd
3 changed files with 55 additions and 26 deletions
  1. +2
    -0
      WHATSNEW
  2. +5
    -0
      docs/manual/CoreTasks/cvs.html
  3. +48
    -26
      src/main/org/apache/tools/ant/taskdefs/Cvs.java

+ 2
- 0
WHATSNEW View File

@@ -42,6 +42,8 @@ Fixed bugs:
Other changes:
--------------

* Added support for specifying CVS_RSH in the <cvs/> task

* New tasks bzip2 and bunzip2 to pack and unpack files using the
BZip2 alogrithm, replaceregexp, checksum



+ 5
- 0
docs/manual/CoreTasks/cvs.html View File

@@ -30,6 +30,11 @@ preferred over the <i>checkout</i> command, because of speed.</p>
<td valign="top">the CVSROOT variable.</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">cvsRsh</td>
<td valign="top">the CVS_RSH variable.</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">dest</td>
<td valign="top">the directory where the checked out files should be placed.</td>


+ 48
- 26
src/main/org/apache/tools/ant/taskdefs/Cvs.java View File

@@ -54,17 +54,17 @@

package org.apache.tools.ant.taskdefs;

import org.apache.tools.ant.Task;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.Environment;
import java.io.File;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
*
@@ -83,6 +83,11 @@ public class Cvs extends Task {
*/
private String cvsRoot;

/**
* the CVS_RSH variable.
*/
private String cvsRsh;

/**
* the package/module to check out.
*/
@@ -179,9 +184,16 @@ public class Cvs extends Task {
env.addVariable(var);
}

if(cvsRsh!=null){
Environment.Variable var = new Environment.Variable();
var.setKey("CVS_RSH");
var.setValue(String.valueOf(cvsRsh));
env.addVariable(var);
}

ExecuteStreamHandler streamhandler = null;
OutputStream outputstream = null;
OutputStream errorstream = null;
OutputStream errorstream = null;
if (error == null && output == null) {
streamhandler = new LogStreamHandler(this, Project.MSG_INFO,
Project.MSG_WARN);
@@ -210,7 +222,7 @@ public class Cvs extends Task {
streamhandler = new PumpStreamHandler(outputstream, errorstream);
}

Execute exe = new Execute(streamhandler,
Execute exe = new Execute(streamhandler,
null);

exe.setAntRun(project);
@@ -220,10 +232,10 @@ public class Cvs extends Task {
exe.setCommandline(toExecute.getCommandline());
exe.setEnvironment(env.getVariables());
try {
int retCode = exe.execute();
/*Throw an exception if cvs exited with error. (Iulian)*/
if(failOnError && retCode != 0)
throw new BuildException("cvs exited with error code "+ retCode);
int retCode = exe.execute();
/*Throw an exception if cvs exited with error. (Iulian)*/
if(failOnError && retCode != 0)
throw new BuildException("cvs exited with error code "+ retCode);
} catch (IOException e) {
throw new BuildException(e, location);
} finally {
@@ -241,15 +253,25 @@ public class Cvs extends Task {
}

public void setCvsRoot(String root) {
// Check if not real cvsroot => set it to null
if (root != null) {
if (root.trim().equals(""))
root = null;
}
// Check if not real cvsroot => set it to null
if (root != null) {
if (root.trim().equals(""))
root = null;
}

this.cvsRoot = root;
}

public void setCvsRsh(String rsh) {
// Check if not real cvsrsh => set it to null
if (rsh != null) {
if (rsh.trim().equals(""))
rsh = null;
}

this.cvsRsh = rsh;
}

public void setPort(int port){
this.port = port;
}
@@ -266,15 +288,15 @@ public class Cvs extends Task {
this.pack = p;
}

public void setTag(String p) {
// Check if not real tag => set it to null
public void setTag(String p) {
// Check if not real tag => set it to null
if (p != null && p.trim().length() > 0) {
cmd.createArgument().setValue("-r");
cmd.createArgument().setValue(p);
}
}
}


public void setDate(String p) {
if(p != null && p.trim().length() > 0) {
cmd.createArgument().setValue("-D");
@@ -285,11 +307,11 @@ public class Cvs extends Task {
public void setCommand(String c) {
this.command = c;
}
public void setQuiet(boolean q) {
quiet = q;
}
public void setNoexec(boolean ne) {
noexec = ne;
}
@@ -297,13 +319,13 @@ public class Cvs extends Task {
public void setOutput(File output) {
this.output = output;
}
public void setError(File error) {
this.error = error;
}

public void setFailOnError(boolean failOnError) {
this.failOnError = failOnError;
this.failOnError = failOnError;
}
}



Loading…
Cancel
Save