From d5e9b4accd4de9d534bb1ad65c6c2737c062bb38 Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Mon, 19 Nov 2001 10:54:50 +0000 Subject: [PATCH] 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 --- WHATSNEW | 2 + docs/manual/CoreTasks/cvs.html | 5 ++ .../org/apache/tools/ant/taskdefs/Cvs.java | 74 ++++++++++++------- 3 files changed, 55 insertions(+), 26 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index 73cc337cf..1aeaf0923 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -42,6 +42,8 @@ Fixed bugs: Other changes: -------------- +* Added support for specifying CVS_RSH in the task + * New tasks bzip2 and bunzip2 to pack and unpack files using the BZip2 alogrithm, replaceregexp, checksum diff --git a/docs/manual/CoreTasks/cvs.html b/docs/manual/CoreTasks/cvs.html index 4c6bd4b16..5c389d400 100644 --- a/docs/manual/CoreTasks/cvs.html +++ b/docs/manual/CoreTasks/cvs.html @@ -30,6 +30,11 @@ preferred over the checkout command, because of speed.

the CVSROOT variable. No + + cvsRsh + the CVS_RSH variable. + No + dest the directory where the checked out files should be placed. diff --git a/src/main/org/apache/tools/ant/taskdefs/Cvs.java b/src/main/org/apache/tools/ant/taskdefs/Cvs.java index 22312fb48..04d348d98 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Cvs.java +++ b/src/main/org/apache/tools/ant/taskdefs/Cvs.java @@ -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; } }