/** * Creates a new execute object using <code>PumpStreamHandler</code> for * stream handling. */ public Execute() { this(new PumpStreamHandler(), null); }
/** * Create the ExecuteStreamHandler instance that will be used * during execution. * @return <code>ExecuteStreamHandler</code>. * @throws BuildException on error. */ @Override protected ExecuteStreamHandler createHandler() throws BuildException { //if we have a RedirectorElement, return a decoy return (redirectorElement == null) ? super.createHandler() : new PumpStreamHandler(); }
/** * find the handler and instantiate it if it does not exist yet * @return handler for output and error streams */ protected ExecuteStreamHandler getExecuteStreamHandler() { if (this.executeStreamHandler == null) { setExecuteStreamHandler(new PumpStreamHandler(getOutputStream(), getErrorStream())); } return this.executeStreamHandler; }
try { ByteArrayOutputStream out = new ByteArrayOutputStream(); Execute exe = new Execute(new PumpStreamHandler(out)); exe.setCommandline(getProcEnvCommand());
ExecuteStreamHandler handler = new PumpStreamHandler(dummyOut); handler.setProcessErrorStream(process.getErrorStream()); handler.setProcessOutputStream(process.getInputStream());
/** * Create the StreamHandler to use with our Execute instance. * * @return the execute stream handler to manage the input, output and error * streams. * * @throws BuildException * if the execute stream handler cannot be created. */ public ExecuteStreamHandler createHandler() throws BuildException { createStreams(); final boolean nonBlockingRead = input == null && inputString == null; return new PumpStreamHandler(getOutputStream(), getErrorStream(), getInputStream(), nonBlockingRead); }
errorstream = new LogOutputStream(this, Project.MSG_DEBUG); streamhandler = new PumpStreamHandler(outputstream, errorstream);
log(commandLine.describeCommand(), Project.MSG_VERBOSE); try { result = runCmd(commandLine, new PumpStreamHandler(fos, new LogOutputStream(this, Project.MSG_WARN))); } finally {
final Execute exe = new Execute(new PumpStreamHandler(out, err)); exe.setAntRun(getProject());
/** * Creates a new execute object using <code>PumpStreamHandler</code> for stream handling. */ public SSHExecute() { this(new PumpStreamHandler()); }
/** * 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); }
/** * 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); }
public void execute(String command, List<String> args, InputStream in, OutputStream out) throws Exception { List<String> cmdLine = new ArrayList<String>(); if (isWindows()) { cmdLine.add("cmd.exe"); cmdLine.add("/c"); } cmdLine.add(resolveCommandForOS(command)); // add command-specific arguments cmdLine.addAll(getCommandArguments(command)); // add user arguments if (args != null) { cmdLine.addAll(args); } ExecuteWatchdog watchdog = new ExecuteWatchdog( timeout ); ExecuteStreamHandler streamHandler = new PumpStreamHandler( out, out, in ); Execute exec = new Execute( streamHandler, watchdog ); exec.setCommandline( cmdLine.toArray(new String[] {}) ); List<String> env = getCommandEnvironment(command); if (!env.isEmpty()) { exec.setEnvironment(env.toArray(new String[] {}) ); } exec.execute(); }
/** * Copied from spawn, but actually returns the Process, instead of void * @return the spawned process handle */ public Process asyncSpawn() throws IOException { if (!environmentBuilder.isEmpty()) { setActualExecuteEnvironment(); } if (workingDirectory != null && !workingDirectory.exists()) { throw new BuildException(workingDirectory + " doesn't exist."); } final Process process = launch(project, getCommandline(), getEnvironment(), workingDirectory, useVMLauncher); if (Os.isFamily("windows")) { AsyncExecute.sleepTight(1000); } OutputStream dummyOut = new OutputStream() { public void write(int b) throws IOException { } }; ExecuteStreamHandler streamHandler = new PumpStreamHandler(dummyOut); streamHandler.setProcessErrorStream(process.getErrorStream()); streamHandler.setProcessOutputStream(process.getInputStream()); streamHandler.start(); project.log("spawned process " + process.toString(), Project.MSG_VERBOSE); return process; }
/** * Copied from spawn, but actually returns the Process, instead of void * @return the spawned process handle */ public Process asyncSpawn() throws IOException { if (!environmentBuilder.isEmpty()) { setActualExecuteEnvironment(); } if (workingDirectory != null && !workingDirectory.exists()) { throw new BuildException(workingDirectory + " doesn't exist."); } final Process process = launch(project, getCommandline(), getEnvironment(), workingDirectory, useVMLauncher); if (Os.isFamily("windows")) { AsyncExecute.sleepTight(1000); } OutputStream dummyOut = new OutputStream() { public void write(int b) throws IOException { } }; ExecuteStreamHandler streamHandler = new PumpStreamHandler(dummyOut); streamHandler.setProcessErrorStream(process.getErrorStream()); streamHandler.setProcessOutputStream(process.getInputStream()); streamHandler.start(); project.log("spawned process " + process.toString(), Project.MSG_VERBOSE); return process; }
try final Execute exec = new Execute(new PumpStreamHandler(System.out, System.out)); //to avoid red colored text in obfuscator output exec.setAntRun(getProject()); exec.setVMLauncher(true);
try final Execute exec = new Execute(new PumpStreamHandler(System.out, System.out)); //to avoid red colored text in obfuscator output exec.setAntRun(getProject()); exec.setVMLauncher(true);