/** * Fulfill the condition interface. * @return the result of evaluating the specified return code. */ public boolean eval() { return Execute.isFailure(code); }
/** * Did this execute return in a failure. * * @see #isFailure(int) * @return true if and only if the exit code is interpreted as a failure * @since Ant1.7 */ public boolean isFailure() { return isFailure(getExitValue()); }
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()); } }
/** * Executes the task. * <p> * Builds a command line to execute ss.exe and then calls Exec's run method * to execute the command line. * </p> * * @throws BuildException if the command cannot execute. */ public void execute() throws BuildException { Commandline commandLine = buildCmdLine(); int result = run(commandLine); if (Execute.isFailure(result) && getFailOnError()) { String msg = "Failed executing: " + formatCommandLine(commandLine) + " With a return code of " + result; throw new BuildException(msg, getLocation()); } }
/** * check the file given by getFile(). */ private void doit() { Commandline commandLine = new Commandline(); // build the command line from what we got the format is // ccm co /t .. files // as specified in the CCM.EXE help commandLine.setExecutable(getCcmCommand()); commandLine.createArgument().setValue(getCcmAction()); checkOptions(commandLine); int result = run(commandLine); if (Execute.isFailure(result)) { throw new BuildException("Failed executing: " + commandLine, getLocation()); } }
if (Execute.isFailure(returnCode)) { if (failOnError) { throw new BuildException(getTaskType() + " returned: "
/** * 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()); } }
/** * Executes the task. * <p> * Builds a command line to execute ccm and then calls Exec's run method * to execute the command line. * </p> * @throws BuildException on error */ @Override public void execute() throws BuildException { Commandline commandLine = new Commandline(); // build the command line from what we got the format // as specified in the CCM.EXE help commandLine.setExecutable(getCcmCommand()); commandLine.createArgument().setValue(getCcmAction()); checkOptions(commandLine); int result = run(commandLine); if (Execute.isFailure(result)) { throw new BuildException("Failed executing: " + commandLine, getLocation()); } }
if (Execute.isFailure(result) && getFailOnErr()) { throw new BuildException("Failed executing: " + commandLine, getLocation());
/** * Executes the task. * <p> * Builds a command line to execute cleartool and then calls Exec's run method * to execute the command line. * @throws BuildException if the command fails and failonerr is set to true */ @Override public void execute() throws BuildException { Commandline commandLine = new Commandline(); // Check for required attributes if (getTypeName() == null) { throw new BuildException("Required attribute TypeName not specified"); } // build the command line from what we got. the format is // cleartool mklbtype [options...] type-selector... // as specified in the CLEARTOOL help commandLine.setExecutable(getClearToolCommand()); commandLine.createArgument().setValue(COMMAND_MKLBTYPE); checkOptions(commandLine); if (!getFailOnErr()) { getProject().log("Ignoring any errors that occur for: " + getTypeSpecifier(), Project.MSG_VERBOSE); } int result = run(commandLine); if (Execute.isFailure(result) && getFailOnErr()) { throw new BuildException("Failed executing: " + commandLine, getLocation()); } }
if (Execute.isFailure(result) && getFailOnErr()) { throw new BuildException("Failed executing: " + commandLine, getLocation());
if (Execute.isFailure(result) && getFailOnErr()) { throw new BuildException("Failed executing: " + commandLine, getLocation());
if (Execute.isFailure(result) && getFailOnErr()) { throw new BuildException("Failed executing: " + commandLine, getLocation());
/** * Executes the task. * <p> * Builds a command line to execute cleartool and then calls Exec's run method * to execute the command line. * @throws BuildException if the command fails and failonerr is set to true */ @Override public void execute() throws BuildException { Commandline commandLine = new Commandline(); Project aProj = getProject(); // Default the viewpath to basedir if it is not specified if (getViewPath() == null) { setViewPath(aProj.getBaseDir().getPath()); } // build the command line from what we got. the format is // cleartool checkin [options...] [viewpath ...] // as specified in the CLEARTOOL.EXE help commandLine.setExecutable(getClearToolCommand()); commandLine.createArgument().setValue(COMMAND_CHECKIN); checkOptions(commandLine); if (!getFailOnErr()) { getProject().log("Ignoring any errors that occur for: " + getViewPathBasename(), Project.MSG_VERBOSE); } int result = run(commandLine); if (Execute.isFailure(result) && getFailOnErr()) { throw new BuildException("Failed executing: " + commandLine, getLocation()); } }
if (Execute.isFailure(result) && getFailOnErr()) { throw new BuildException("Failed executing: " + commandLine, getLocation());
if (Execute.isFailure(result) && getFailOnErr()) { throw new BuildException("Failed executing: " + commandLine, getLocation());
if (Execute.isFailure(result) && getFailOnErr()) { throw new BuildException("Failed executing: " + commandLine, getLocation());
exe.setCommandline(args); exe.execute(); return !exe.isFailure(); } catch (IOException exception) { throw new BuildException("Error running " + executable
if (Execute.isFailure(run(commandLine, this))) { throw new BuildException("Failed executing: " + commandLine, getLocation());
exe.setCommandline(args); exe.execute(); return !exe.isFailure(); } catch (IOException exception) { throw new BuildException("Error running " + getExecutableName()