/** * Size operator. This actually creates the command line, so it is not * a zero cost operation. * @return number of elements in the command, including the executable. */ public int size() { return getCommandline().length; }
/** * Return a String that describes the command and arguments suitable for * verbose output before a call to <code>Runtime.exec(String[])</code>. * @param line the Commandline to describe. * @return a string that describes the command and arguments. * @since Ant 1.5 */ public static String describeCommand(Commandline line) { return describeCommand(line.getCommandline()); }
/** * Return the command line as a string. * @return the command line. */ @Override public String toString() { return toString(getCommandline()); }
/** * Performs the actual compilation. */ public boolean compile(Javah javah) throws BuildException { Commandline cmd = setupGcjhCommand(javah); try { Execute.runCommand(javah, cmd.getCommandline()); return true; } catch (BuildException e) { if (!e.getMessage().contains("failed with return code")) { throw e; } } return false; }
/** * Performs the actual compilation. * @param javah the calling javah task. * @return true if the compilation was successful. * @throws BuildException if there is an error. * @since Ant 1.6.3 */ public boolean compile(Javah javah) throws BuildException { Commandline cmd = setupKaffehCommand(javah); try { Execute.runCommand(javah, cmd.getCommandline()); return true; } catch (BuildException e) { if (!e.getMessage().contains("failed with return code")) { throw e; } } return false; }
/** * Run the command using the given Execute instance. This may be * overridden by subclasses. * * @param exe instance of Execute to run. * * @throws BuildException if the new process could not be started * only if failIfExecFails is set to true (the default). */ protected void runExec(Execute exe) throws BuildException { // show the command log(cmdl.describeCommand(), Project.MSG_VERBOSE); exe.setCommandline(cmdl.getCommandline()); try { runExecute(exe); } catch (IOException e) { if (failIfExecFails) { throw new BuildException("Execute failed: " + e.toString(), e, getLocation()); } log("Execute failed: " + e.toString(), Project.MSG_ERR); } finally { // close the output file if required logFlush(); } }
/** * Performs a compile using the gcj compiler. * @return true if the compilation succeeded * @throws BuildException on error */ @Override public boolean execute() throws BuildException { attributes.log("Using gcj compiler", Project.MSG_VERBOSE); Commandline cmd = setupGCJCommand(); int firstFileName = cmd.size(); logAndAddFilesToCompile(cmd); return executeExternalCompile(cmd.getCommandline(), firstFileName) == 0; }
script.setProperty("target", getOwningTarget()); script.setProperty("task", this); script.setProperty("args", cmdline.getCommandline()); if (mavenPom != null) { script.setProperty("pom", mavenPom);
/** * 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()); } }
/** * Performs a compile using the sj compiler from Symantec. * @return true if the compilation succeeded * @throws BuildException on error */ @Override public boolean execute() throws BuildException { attributes.log("Using symantec java compiler", Project.MSG_VERBOSE); Commandline cmd = setupJavacCommand(); String exec = getJavac().getExecutable(); cmd.setExecutable(exec == null ? "sj" : exec); int firstFileName = cmd.size() - compileList.length; return executeExternalCompile(cmd.getCommandline(), firstFileName) == 0; }
/** * 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()); } }
/** * 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 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()); } }
Project.MSG_WARN), null); exe.setCommandline(toExecute.getCommandline());
.getPath()); try { execute.setCommandline(cloned.getCommandline()); runExecute(execute); } catch (IOException e) {
exe.setCommandline(cmd.getCommandline());
String[] args = cmd.getCommandline();
String[] args = cmd.getCommandline();
/** * Performs a compile using the Javac externally. * @return true if the compilation succeeded * @throws BuildException on error */ @Override public boolean execute() throws BuildException { attributes.log("Using external javac compiler", Project.MSG_VERBOSE); Commandline cmd = new Commandline(); cmd.setExecutable(getJavac().getJavacExecutable()); if (!assumeJava11() && !assumeJava12()) { setupModernJavacCommandlineSwitches(cmd); } else { setupJavacCommandlineSwitches(cmd, true); } int firstFileName = assumeJava11() ? -1 : cmd.size(); logAndAddFilesToCompile(cmd); //On VMS platform, we need to create a special java options file //containing the arguments and classpath for the javac command. //The special file is supported by the "-V" switch on the VMS JVM. if (Os.isFamily("openvms")) { return execOnVMS(cmd, firstFileName); } return executeExternalCompile(cmd.getCommandline(), firstFileName, true) == 0; }