diff --git a/docs/index.html b/docs/index.html index 9ec3210fd..b3b8b945c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1372,6 +1372,16 @@ preferred over the checkout command, because of speed.
<cvs cvsRoot=":pserver:anoncvs@jakarta.apache.org:/home/cvspublic" diff --git a/src/main/org/apache/tools/ant/taskdefs/Cvs.java b/src/main/org/apache/tools/ant/taskdefs/Cvs.java index 126821aea..6379135fb 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Cvs.java +++ b/src/main/org/apache/tools/ant/taskdefs/Cvs.java @@ -69,21 +69,55 @@ import java.io.*; public class Cvs extends Task { private Commandline cmd = new Commandline(); + + /** + * the CVSROOT variable. + */ private String cvsRoot; + + /** + * the package/module to check out. + */ private String pack; + + /** + * the CVS command to execute. + */ private String command = "checkout"; + + /** + * suppress information messages. + */ private boolean quiet = false; + + /** + * report only, don't change any files. + */ private boolean noexec = false; + + /** + * the directory where the checked out files should be placed. + */ private File dest; - + + /** + * the file to direct standard output from the command. + */ + private File output; + + /** + * the file to direct standard error from the command. + */ + private File error; + public void execute() throws BuildException { - // XXX: we should use JCVS (www.ice.com/JCVS) instead of command line - // execution so that we don't rely on having native CVS stuff around (SM) + // XXX: we should use JCVS (www.ice.com/JCVS) instead of command line + // execution so that we don't rely on having native CVS stuff around (SM) // We can't do it ourselves as jCVS is GPLed, a third party task // outside of jakarta repositories would be possible though (SB). - + Commandline toExecute = new Commandline(); toExecute.setExecutable("cvs"); @@ -100,12 +134,42 @@ public class Cvs extends Task { toExecute.createArgument().setLine(command); toExecute.addArguments(cmd.getCommandline()); - if (pack != null) { + if (pack != null) { toExecute.createArgument().setValue(pack); - } + } + + ExecuteStreamHandler streamhandler = null; + OutputStream outputstream = null; + OutputStream errorstream = null; + if (error == null && output == null) { + streamhandler = new LogStreamHandler(this, Project.MSG_INFO, + Project.MSG_WARN); + } + else { + if (output != null) { + try { + outputstream = new PrintStream(new BufferedOutputStream(new FileOutputStream(output))); + } catch (IOException e) { + throw new BuildException(e, location); + } + } + else { + outputstream = new LogOutputStream(this, Project.MSG_INFO); + } + if (error != null) { + try { + errorstream = new PrintStream(new BufferedOutputStream(new FileOutputStream(error))); + } catch (IOException e) { + throw new BuildException(e, location); + } + } + else { + errorstream = new LogOutputStream(this, Project.MSG_WARN); + } + streamhandler = new PumpStreamHandler(outputstream, errorstream); + } - Execute exe = new Execute(new LogStreamHandler(this, Project.MSG_INFO, - Project.MSG_WARN), + Execute exe = new Execute(streamhandler, null); exe.setAntRun(project); @@ -117,6 +181,17 @@ public class Cvs extends Task { exe.execute(); } catch (IOException e) { throw new BuildException(e, location); + } finally { + if (output != null) { + try { + outputstream.close(); + } catch (IOException e) {} + } + if (error != null) { + try { + errorstream.close(); + } catch (IOException e) {} + } } } @@ -127,7 +202,7 @@ public class Cvs extends Task { root = null; } - this.cvsRoot = root; + this.cvsRoot = root; } public void setDest(File dest) { @@ -135,7 +210,7 @@ public class Cvs extends Task { } public void setPackage(String p) { - this.pack = p; + this.pack = p; } public void setTag(String p) { @@ -155,7 +230,7 @@ public class Cvs extends Task { } public void setCommand(String c) { - this.command = c; + this.command = c; } public void setQuiet(boolean q) { @@ -165,6 +240,14 @@ public class Cvs extends Task { public void setNoexec(boolean ne) { noexec = ne; } + + public void setOutput(File output) { + this.output = output; + } + + public void setError(File error) { + this.error = error; + } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Javac.java b/src/main/org/apache/tools/ant/taskdefs/Javac.java index 5ceb4b1d1..3a089cfff 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javac.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javac.java @@ -398,7 +398,7 @@ public class Javac extends MatchingTask { * @param addRuntime Shallrt.jar
or *classes.zip
be added to the classpath. */ - private Path getCompileClasspath(boolean addRuntime) { + protected Path getCompileClasspath(boolean addRuntime) { Path classpath = new Path(project); // add dest dir to classpath so that previously compiled and @@ -598,7 +598,7 @@ public class Javac extends MatchingTask { * Logs the compilation parameters, adds the files to compile and logs the * &qout;niceSourceList" */ - private void logAndAddFilesToCompile(Commandline cmd) { + protected void logAndAddFilesToCompile(Commandline cmd) { log("Compilation args: " + cmd.toString(), Project.MSG_VERBOSE); @@ -742,7 +742,7 @@ public class Javac extends MatchingTask { * @param args - arguments to pass to process on command line * @param firstFileName - index of the first source file in args */ - private int executeJikesCompile(String[] args, int firstFileName) { + protected int executeJikesCompile(String[] args, int firstFileName) { String[] commandArray = null; File tmpFile = null; @@ -804,7 +804,7 @@ public class Javac extends MatchingTask { * so that you don't have to specify them all one by one. * @param classpath - Path to append files to */ - private void addExtdirsToClasspath(Path classpath) { + protected void addExtdirsToClasspath(Path classpath) { if (extdirs == null) { String extProp = System.getProperty("java.ext.dirs"); if (extProp != null) {