/** * Run the command. * @param cmd the command line * @return the exit status of the command */ protected int run(Commandline cmd) { return run(cmd, new LogStreamHandler(this, Project.MSG_VERBOSE, Project.MSG_WARN)); }
/** * 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()); } }
new LogStreamHandler(attributes, Project.MSG_INFO, Project.MSG_WARN));
/** * 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()); } }
/** * 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()); } }
new Execute(new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_INFO),
new Execute(new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_INFO),
Execute exe = new Execute(new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN));
Execute exe = new Execute(new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN), null);
Execute exe = new Execute(new LogStreamHandler(javah, Project.MSG_INFO, Project.MSG_WARN));
Execute exe = new Execute(new LogStreamHandler(owner, Project.MSG_INFO, Project.MSG_WARN));
if (error == null && output == null) { if (!quiet) { streamhandler = new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN); } else { streamhandler = new LogStreamHandler(this, Project.MSG_DEBUG, Project.MSG_DEBUG);
log("Executing " + commandLine.toString(), Project.MSG_VERBOSE); result = runCmd(commandLine, new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN)); if (result != 0 && !ignorerc) { String msg = "Failed executing: " + commandLine.toString()
private int executeRunnerClassAsForked() throws BuildException { CommandlineJava cmd = initializeJavaCommand(); Execute execute = new Execute(new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN)); String[] commandLine = cmd.getCommandline(); log("Executing: " + StringUtils.join(Arrays.asList(commandLine), " ")); execute.setCommandline(commandLine); execute.setNewenvironment(false); execute.setAntRun(getProject()); log(cmd.describeCommand(), Project.MSG_VERBOSE); int retVal; try { retVal = execute.execute(); } catch (IOException e) { throw new BuildException("Process fork failed.", e, getLocation()); } return retVal; }
private int executeRunnerClassAsForked() throws BuildException { CommandlineJava cmd = initializeJavaCommand(); Execute execute = new Execute(new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN)); String[] commandLine = cmd.getCommandline(); log("Executing: " + StringUtils.join(Arrays.asList(commandLine), " ")); execute.setCommandline(commandLine); execute.setNewenvironment(false); execute.setAntRun(getProject()); log(cmd.describeCommand(), Project.MSG_VERBOSE); int retVal; try { retVal = execute.execute(); } catch (IOException e) { throw new BuildException("Process fork failed.", e, getLocation()); } return retVal; }
/** * Executes the given classname with the given arguments in a separate VM. */ private int run(String[] command) throws BuildException { LogStreamHandler logstr = new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN); Execute exe = new Execute(logstr); exe.setAntRun(project); exe.setCommandline(command); try { int rc = exe.execute(); if (exe.killedProcess()) { log("Timeout: killed the sub-process", Project.MSG_WARN); } return rc; } catch (IOException e) { throw new BuildException(e, location); } }
/** * Executes the given classname with the given arguments in a separate VM. */ private int run(String[] command) throws BuildException { LogStreamHandler logstr = new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN); Execute exe = new Execute(logstr); exe.setAntRun(project); exe.setCommandline(command); try { int rc = exe.execute(); if (exe.killedProcess()) { log("Timeout: killed the sub-process", Project.MSG_WARN); } return rc; } catch (IOException e) { throw new BuildException(e, location); } }
public void execute() throws BuildException { buildCommandLine(); LogStreamHandler log = new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN); Execute exe = new Execute(log); exe.setAntRun(getProject()); exe.setCommandline(cmd.getCommandline()); try { int rc = exe.execute(); if (exe.killedProcess() || rc != 0) { throw new BuildException("wsdl2java failed", getLocation()); } } catch (IOException e) { throw new BuildException(e, getLocation()); } }
public void execute() throws BuildException { buildCommandLine(); LogStreamHandler log = new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN); Execute exe = new Execute(log); exe.setAntRun(getProject()); exe.setCommandline(cmd.getCommandline()); try { int rc = exe.execute(); if (exe.killedProcess() || rc != 0) { throw new BuildException("java2ws failed", getLocation()); } } catch (IOException e) { throw new BuildException(e, getLocation()); } }
private int run(String[] command) throws BuildException { Execute exe; LogStreamHandler logstr = new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN); exe = new Execute(logstr); exe.setAntRun(getProject()); exe.setCommandline(command); try { int rc = exe.execute(); if (exe.killedProcess()) { log("Timeout: killed the sub-process", Project.MSG_WARN); } return rc; } catch (IOException e) { throw new BuildException(e, getLocation()); } } }