/** * Set the working dir of the new process. * @param exe executable. * @throws BuildException if the dir doesn't exist. */ private void setupWorkingDir(Execute exe) { if (dir == null) { dir = getProject().getBaseDir(); } else if (!dir.isDirectory()) { throw new BuildException(dir.getAbsolutePath() + " is not a valid directory", getLocation()); } exe.setWorkingDirectory(dir); }
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()); } }
Execute exe = new Execute(jop); exe.setAntRun(project); exe.setWorkingDirectory(project.getBaseDir()); exe.setCommandline(commandArray); exe.execute();
exe.setWorkingDirectory(project.getBaseDir()); exe.setCommandline(commandArray); exe.execute();
/** * 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()); } }
exe.setWorkingDirectory(getProject().getBaseDir()); } else { if (!directory.isDirectory()) { getLocation()); exe.setWorkingDirectory(directory);
if(m_workingDir != null) { if(m_workingDir.exists() && m_workingDir.isDirectory()) { execute.setWorkingDirectory(m_workingDir);
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); } } }
/** * Get the execute object. * @param toExecute the command line to use. * @param streamhandler the stream handler to use. * @return the execute object. * @since Ant 1.6.3 */ protected Execute getExecute(Commandline toExecute, ExecuteStreamHandler streamhandler) { Execute exe = new Execute(streamhandler, null); exe.setAntRun(getProject()); if (topDir == null) { topDir = getProject().getBaseDir(); } exe.setWorkingDirectory(topDir); exe.setCommandline(toExecute.getCommandline()); return exe; } }
/** * 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()); } }
exe.setWorkingDirectory(dest); exe.setCommandline(toExecute.getCommandline()); exe.setEnvironment(env.getVariables());
if (m_workingDir != null) { if (m_workingDir.exists() && m_workingDir.isDirectory()) { execute.setWorkingDirectory(m_workingDir); } else { log("Ignoring invalid working directory : " + m_workingDir, Project.MSG_WARN);
/** * 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()); } }
exe.setWorkingDirectory(getProject().getBaseDir()); exe.setCommandline(cmd.getCommandline());
Project.MSG_WARN)); exe.setAntRun(project); exe.setWorkingDirectory(project.getBaseDir()); exe.setCommandline(args); exe.execute();
Project.MSG_WARN)); exe.setAntRun(project); exe.setWorkingDirectory(project.getBaseDir()); exe.setCommandline(args); exe.execute();
exe.setWorkingDirectory(null); try { exe.setCommandline(toExecute.getCommandline());
Project project = getTask().getProject(); execTask.setAntRun(project); execTask.setWorkingDirectory(project.getBaseDir());
/** * Create an Execute instance with the correct working directory set. * * @return an instance of the Execute class. * * @throws BuildException under unknown circumstances. */ protected Execute prepareExec() throws BuildException { // default directory to the project's base directory if (dir == null) { dir = getProject().getBaseDir(); } if (redirectorElement != null) { redirectorElement.configure(redirector); } Execute exe = new Execute(createHandler(), createWatchdog()); exe.setAntRun(getProject()); exe.setWorkingDirectory(dir); exe.setVMLauncher(vmLauncher); String[] environment = env.getVariables(); if (environment != null) { for (String variable : environment) { log("Setting environment variable: " + variable, Project.MSG_VERBOSE); } } exe.setNewenvironment(newEnvironment); exe.setEnvironment(environment); return exe; }