/** * This needs to be public to allow configuration * of commands externally. * * @param arg command argument */ public void addCommandArgument(String arg) { this.addCommandArgument(cmd, arg); }
/** * Adds direct command-line to execute. * * @param c command line to execute */ public void addConfiguredCommandline(Commandline c) { this.addConfiguredCommandline(c, false); }
/** * find the handler and instantiate it if it does not exist yet * * @return handler for output and error streams */ protected ExecuteStreamHandler getExecuteStreamHandler(InputStream input) { return new PumpStreamHandler(getOutputStream(), getErrorStream(), input); }
this.setPassfile(defaultPassFile); var.setValue(String.valueOf(passFile)); env.addVariable(var); log("Using cvs passfile: " + String.valueOf(passFile), Project.MSG_INFO); } else if (!passFile.canRead()) { log("cvs passfile: " + String.valueOf(passFile) + " ignored as it is not readable", Project.MSG_WARN); } else { log("cvs passfile: " + String.valueOf(passFile) + " ignored as it is not a file", Project.MSG_WARN); Execute exe = new Execute(getExecuteStreamHandler(input), null); exe.setAntRun(getProject()); if (dest == null) { dest = getProject().getBaseDir(); String actualCommandLine = executeToString(exe); log(actualCommandLine, Project.MSG_VERBOSE); int retCode = exe.execute(); log("retCode=" + retCode, Project.MSG_DEBUG); + "Command line was [" + actualCommandLine + "] in " + dest + "\nInput text:\nSTART==>" + inputText + "<==END", getLocation());
/** * do the work * * @throws BuildException if failonerror is set to true and the cvs command fails. */ public void execute() throws BuildException { String savedCommand = getCommand(); if (this.getCommand() == null && vecCommandlines.size() == 0) { // re-implement legacy behaviour: this.setCommand(AbstractCvsTask.DEFAULT_COMMAND); } String c = this.getCommand(); Commandline cloned = null; if (c != null) { cloned = (Commandline) cmd.clone(); cloned.createArgument(true).setLine(c); this.addConfiguredCommandline(cloned, true); } try { for (int i = 0; i < vecCommandlines.size(); i++) { this.runCommand((Commandline) vecCommandlines.elementAt(i)); } } finally { if (cloned != null) { removeCommandline(cloned); } setCommand(savedCommand); } }
/** * access the stream to which the stdout from cvs should go * if this stream has already been set, it will be returned * if the stream has not yet been set, if the attribute output * has been set, the output stream will go to the output file * otherwise the output will go to ant's logging system * * @return output stream to which cvs' stdout should go to */ protected OutputStream getOutputStream() { if (this.outputStream == null) { if (output != null) { try { setOutputStream(new PrintStream( new BufferedOutputStream( new FileOutputStream(output .getPath(), append)))); } catch (IOException e) { throw new BuildException(e, getLocation()); } } else { setOutputStream(new LogOutputStream(this, Project.MSG_INFO)); } } return this.outputStream; }
/** * access the stream to which the stderr from cvs should go * if this stream has already been set, it will be returned * if the stream has not yet been set, if the attribute error * has been set, the output stream will go to the file denoted by the error attribute * otherwise the stderr output will go to ant's logging system * * @return output stream to which cvs' stderr should go to */ protected OutputStream getErrorStream() { if (this.errorStream == null) { if (error != null) { try { setErrorStream(new PrintStream( new BufferedOutputStream( new FileOutputStream(error.getPath(), append)))); } catch (IOException e) { throw new BuildException(e, getLocation()); } } else { setErrorStream(new LogOutputStream(this, Project.MSG_WARN)); } } return this.errorStream; }
/** * Configures and adds the given Commandline. * * @param c commandline to insert * @param insertAtStart If true, c is * inserted at the beginning of the vector of command lines */ public void addConfiguredCommandline(Commandline c, boolean insertAtStart) { if (c == null) { return; } this.configureCommandline(c); if (insertAtStart) { vecCommandlines.insertElementAt(c, 0); } else { vecCommandlines.addElement(c); } }
super.execute(); } finally { final String errors = handler.getErrors();
this.setPassfile(defaultPassFile); var.setValue(String.valueOf(passFile)); env.addVariable(var); log("Using cvs passfile: " + String.valueOf(passFile), Project.MSG_INFO); } else if (!passFile.canRead()) { log("cvs passfile: " + String.valueOf(passFile) + " ignored as it is not readable", Project.MSG_WARN); } else { log("cvs passfile: " + String.valueOf(passFile) + " ignored as it is not a file", Project.MSG_WARN); Execute exe = new Execute(getExecuteStreamHandler(input), null); exe.setAntRun(getProject()); if (dest == null) { dest = getProject().getBaseDir(); String actualCommandLine = executeToString(exe); log(actualCommandLine, Project.MSG_VERBOSE); int retCode = exe.execute(); log("retCode=" + retCode, Project.MSG_DEBUG); + "Command line was [" + actualCommandLine + "] in " + dest + "\nInput text:\nSTART==>" + inputText + "<==END", getLocation());
/** * do the work * * @throws BuildException if failonerror is set to true and the cvs command fails. */ public void execute() throws BuildException { String savedCommand = getCommand(); if (this.getCommand() == null && vecCommandlines.size() == 0) { // re-implement legacy behaviour: this.setCommand(AbstractCvsTask.DEFAULT_COMMAND); } String c = this.getCommand(); Commandline cloned = null; if (c != null) { cloned = (Commandline) cmd.clone(); cloned.createArgument(true).setLine(c); this.addConfiguredCommandline(cloned, true); } try { for (int i = 0; i < vecCommandlines.size(); i++) { this.runCommand((Commandline) vecCommandlines.elementAt(i)); } } finally { if (cloned != null) { removeCommandline(cloned); } setCommand(savedCommand); } }
/** * access the stream to which the stdout from cvs should go * if this stream has already been set, it will be returned * if the stream has not yet been set, if the attribute output * has been set, the output stream will go to the output file * otherwise the output will go to ant's logging system * * @return output stream to which cvs' stdout should go to */ protected OutputStream getOutputStream() { if (this.outputStream == null) { if (output != null) { try { setOutputStream(new PrintStream( new BufferedOutputStream( new FileOutputStream(output .getPath(), append)))); } catch (IOException e) { throw new BuildException(e, getLocation()); } } else { setOutputStream(new LogOutputStream(this, Project.MSG_INFO)); } } return this.outputStream; }
/** * access the stream to which the stderr from cvs should go * if this stream has already been set, it will be returned * if the stream has not yet been set, if the attribute error * has been set, the output stream will go to the file denoted by the error attribute * otherwise the stderr output will go to ant's logging system * * @return output stream to which cvs' stderr should go to */ protected OutputStream getErrorStream() { if (this.errorStream == null) { if (error != null) { try { setErrorStream(new PrintStream( new BufferedOutputStream( new FileOutputStream(error.getPath(), append)))); } catch (IOException e) { throw new BuildException(e, getLocation()); } } else { setErrorStream(new LogOutputStream(this, Project.MSG_WARN)); } } return this.errorStream; }
/** * Configures and adds the given Commandline. * * @param c commandline to insert * @param insertAtStart If true, c is * inserted at the beginning of the vector of command lines */ public void addConfiguredCommandline(Commandline c, boolean insertAtStart) { if (c == null) { return; } this.configureCommandline(c); if (insertAtStart) { vecCommandlines.insertElementAt(c, 0); } else { vecCommandlines.addElement(c); } }
super.execute(); } finally { final String errors = handler.getErrors();
/** * find the handler and instantiate it if it does not exist yet * * @return handler for output and error streams */ protected ExecuteStreamHandler getExecuteStreamHandler(InputStream input) { return new PumpStreamHandler(getOutputStream(), getErrorStream(), input); }
/** * This needs to be public to allow configuration * of commands externally. * * @param arg command argument */ public void addCommandArgument(String arg) { this.addCommandArgument(cmd, arg); }
/** * Adds direct command-line to execute. * * @param c command line to execute */ public void addConfiguredCommandline(Commandline c) { this.addConfiguredCommandline(c, false); }
/** * Use the most recent revision no later than the given date. * * @param p a date as string in a format that the CVS executable can understand * see man cvs */ public void setDate(String p) { if (p != null && p.trim().length() > 0) { addCommandArgument("-D"); addCommandArgument(p); } }
/** * Use the most recent revision no later than the given date. * * @param p a date as string in a format that the CVS executable can understand * see man cvs */ public void setDate(String p) { if (p != null && p.trim().length() > 0) { addCommandArgument("-D"); addCommandArgument(p); } }