protected void runPub( IContainer container, final MessageConsole console, List<String> args, boolean wait) { stringBuilder = new StringBuilder(); ProcessBuilder builder = new ProcessBuilder(); builder.directory(container.getLocation().toFile()); builder.redirectErrorStream(true); builder.command(args); final Process process; try { process = builder.start(); final Thread stdoutThread = new Thread( new Runnable() { @Override public void run() { try { copy(process.getInputStream(), console); } catch (IOException e) { // do nothing } } }); stdoutThread.start(); if (wait) { process.waitFor(); } } catch (IOException e) { String message = NLS.bind(PubMessages.RunPubJob_failed, command, e.toString()); console.println(message); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } }
/** * Runs the pub command and displays the output in the console. * * @return the result of running the pub command */ @Override public IStatus run(IProgressMonitor monitor) { IStatus status = runSilent(monitor); if (!status.isOK()) { MessageConsole console = DartCore.getConsole(); console.printSeparator(NLS.bind(PubMessages.RunPubJob_running, command)); console.println(status.getMessage()); } return status; }