private static void executeCommand(File workingDir, String... command) throws IOException { Execute exec = new Execute(); if (workingDir == null) { String homeDir = System.getProperty("user.home"); if (homeDir != null) { workingDir = new File(homeDir); } } if (workingDir != null) { exec.setWorkingDirectory(workingDir); } exec.setCommandline(command); exec.execute(); if (exec.isFailure()) { throw new RuntimeException("Process returned bad exit value: " + exec.getExitValue()); } }
int retval = exe.execute(); if (retval != 0) {
exe.setWorkingDirectory(project.getBaseDir()); exe.setCommandline(commandArray); exe.execute(); } catch (IOException e) { throw new BuildException("Error running Jikes compiler", e);
/** * Executes the given source-file or classname with the given arguments in a separate VM. * @param command String[] of command-line arguments. */ private int fork(String[] command) throws BuildException { Execute exe = new Execute(redirector.createHandler(), createWatchdog()); setupExecutable(exe, command); try { int rc = exe.execute(); redirector.complete(); if (exe.killedProcess()) { throw new BuildException(TIMEOUT_MESSAGE); } return rc; } catch (IOException e) { throw new BuildException(e, getLocation()); } }
/** * Run the command. * @param cmd the command line to use. * @param out the output stream handler to use. * @return the exit code of the command. */ protected int runCmd(Commandline cmd, ExecuteStreamHandler out) { try { Project aProj = getProject(); Execute exe = new Execute(out); exe.setAntRun(aProj); exe.setWorkingDirectory(aProj.getBaseDir()); exe.setCommandline(cmd.getCommandline()); return exe.execute(); } catch (IOException e) { String msg = "Failed executing: " + cmd.toString() + ". Exception: " + e.getMessage(); throw new BuildException(msg, getLocation()); } }
/** * Run the command. * @param cmd the command line * @param handler an execute stream handler * @return the exit status of the command */ protected int run(Commandline cmd, ExecuteStreamHandler handler) { try { Execute exe = new Execute(handler); exe.setAntRun(getProject()); exe.setWorkingDirectory(getProject().getBaseDir()); exe.setCommandline(cmd.getCommandline()); return exe.execute(); } catch (IOException e) { throw new BuildException(e, getLocation()); } }
if (process.execute() != 0) { throw new BuildException("JJDoc failed.");
returnCode = exe.execute();
int retVal; try { retVal= execute.execute();
/** * A utility method that runs an external command. Writes the output and * error streams of the command to the project log. * * @param task The task that the command is part of. Used for logging * @param cmdline The command to execute. * @throws BuildException if the command does not exit successfully. */ public static void runCommand(Task task, String... cmdline) throws BuildException { try { task.log(Commandline.describeCommand(cmdline), Project.MSG_VERBOSE); Execute exe = new Execute( new LogStreamHandler(task, Project.MSG_INFO, Project.MSG_ERR)); exe.setAntRun(task.getProject()); exe.setCommandline(cmdline); int retval = exe.execute(); if (isFailure(retval)) { throw new BuildException(cmdline[0] + " failed with return code " + retval, task.getLocation()); } } catch (IOException exc) { throw new BuildException("Could not launch " + cmdline[0] + ": " + exc, task.getLocation()); } }
private void runForked(String[] commandLine) { final Execute executor = new Execute(); executor.setAntRun(getProject()); executor.setWorkingDirectory(getProject().getBaseDir()); executor.setCommandline(commandLine); try { executor.execute(); } catch (final IOException ioe) { throw new BuildException("Error running forked groovyc.", ioe); } final int returnCode = executor.getExitValue(); if (returnCode != 0) { taskSuccess = false; if (errorProperty != null) { getProject().setNewProperty(errorProperty, "true"); } if (failOnError) { throw new BuildException("Forked groovyc returned error code: " + returnCode); } else { log.error("Forked groovyc returned error code: " + returnCode); } } }
/** * Execute the given command are return success or failure * @param cmd command line to execute * @return the exit status of the subprocess or <code>INVALID</code> */ protected int run(Commandline cmd) { try { Project aProj = getProject(); Execute exe = new Execute( new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN)); exe.setAntRun(aProj); exe.setWorkingDirectory(aProj.getBaseDir()); exe.setCommandline(cmd.getCommandline()); return exe.execute(); } catch (IOException e) { throw new BuildException(e, getLocation()); } }
int returncode = exe.execute(); if (Execute.isFailure(returncode)) { String msg = "'" + PATCH + "' failed with exit code "
int retVal; try { retVal = execute.execute(); } catch (IOException e) { throw new BuildException("Process fork failed.", e, getLocation());
/** * Execute the created command line. * * @param cmd The command line to run. * @return int the exit code. * @throws BuildException if something goes wrong */ protected int run(Commandline cmd) { try { Execute exe = new Execute(new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN)); exe.setAntRun(getProject()); exe.setWorkingDirectory(getProject().getBaseDir()); exe.setCommandline(cmd.getCommandline()); exe.setVMLauncher(false); // Use the OS VM launcher so we get environment variables return exe.execute(); } catch (java.io.IOException e) { throw new BuildException(e, getLocation()); } }
return exe.execute(); } catch (IOException e) { throw new BuildException(e, getLocation());
exe.setWorkingDirectory(project.getBaseDir()); exe.setCommandline(args); exe.execute(); return !exe.isFailure(); } catch (IOException exception) {
log(commandline.describeCommand(), Project.MSG_DEBUG); execTask.setCommandline(commandline.getCommandline()); int result = execTask.execute(); if (Execute.isFailure(result)) { throw new BuildException(
exe.setWorkingDirectory(project.getBaseDir()); exe.setCommandline(args); exe.execute(); return !exe.isFailure(); } catch (IOException exception) {
int rc = exe.execute(); redirector.complete(); return rc;