Package org.apache.tools.ant.taskdefs

Examples of org.apache.tools.ant.taskdefs.Execute



    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 (java.io.IOException e) {
            String msg = "Failed executing: " + cmd.toString() + ". Exception: "+e.getMessage();
            throw new BuildException(msg, location);
        }
View Full Code Here


      cmdl.setExecutable( new File(home, "jplauncher").getAbsolutePath() );
      cmdl.createArgument().setValue("-jp_input=" + paramfile.getAbsolutePath());
     
      // use the custom handler for stdin issues
      LogStreamHandler handler = new CoverageStreamHandler(this);
      Execute exec = new Execute( handler );
      log(cmdl.toString(), Project.MSG_VERBOSE);
      exec.setCommandline(cmdl.getCommandline());
      int exitValue = exec.execute();
      if (exitValue != 0) {
        throw new BuildException("JProbe Coverage failed (" + exitValue + ")");
      }
    } catch (IOException e){
      throw new BuildException("Failed to execute JProbe Coverage.", e);
View Full Code Here

            propsFile.delete();
            throw new BuildException("Error creating temporary properties "
                                     + "file.", e, getLocation());
        }

        Execute execute = new Execute(new LogStreamHandler(this,
                                                           Project.MSG_INFO,
                                                           Project.MSG_WARN),
                                      watchdog);
        execute.setCommandline(cmd.getCommandline());
        execute.setAntRun(getProject());
        if (dir != null) {
            execute.setWorkingDirectory(dir);
        }

        String[] environment = env.getVariables();
        if (environment != null) {
            for (int i = 0; i < environment.length; i++) {
                log("Setting environment variable: " + environment[i],
                    Project.MSG_VERBOSE);
            }
        }
        execute.setNewenvironment(newEnvironment);
        execute.setEnvironment(environment);

        log(cmd.describeCommand(), Project.MSG_VERBOSE);
        int retVal;
        try {
            retVal = execute.execute();
        } catch (IOException e) {
            throw new BuildException("Process fork failed.", e, getLocation());
        } finally {
            if (watchdog != null && watchdog.killedProcess()) {
                logTimeout(feArray, test);
View Full Code Here

    try {
      final LocalSlaveStreamHandler streamHandler =
          new LocalSlaveStreamHandler(eventBus, testsClassLoader, System.err, eventStream,
              sysout, syserr, heartbeat);

      final Execute execute = new Execute();
      execute.setCommandline(commandline.getCommandline());
      execute.setVMLauncher(true);
      File cwd = getWorkingDirectory(slaveInfo);
      execute.setWorkingDirectory(cwd);
      execute.setStreamHandler(streamHandler);
      execute.setNewenvironment(newEnvironment);
      if (env.getVariables() != null)
        execute.setEnvironment(env.getVariables());
      log("Starting JVM J" + slaveInfo.id, Project.MSG_DEBUG);
      int exitStatus = execute.execute();
      log("Forked JVM J" + slaveInfo.id + " finished with exit code: "
          + exitStatus, Project.MSG_DEBUG);

      if (execute.isFailure()) {
        if (exitStatus == SlaveMain.ERR_NO_JUNIT) {
          throw new BuildException("Forked JVM's classpath must include a junit4 JAR.");
        }
        if (exitStatus == SlaveMain.ERR_OLD_JUNIT) {
          throw new BuildException("Forked JVM's classpath must use JUnit 4.10 or newer.");
View Full Code Here

        sb.append("--warning_level ");
        sb.append(m_warningLevel + " ");
       
        arg.setLine(sb.toString());
       
        Execute exe = new Execute();
        setupExecutable(exe, cmdl.getCommandline());
       
        int result = -1;
        try {
            result = exe.execute();
        } catch (IOException e) {
            throw new BuildException(e, getLocation());
        }
       
        if (result != 0) {
View Full Code Here

    private int executeAsForked(final AppletPluginArguments appletPluginArguments) {
        CommandlineJava cmd = AppletRunnerStepBoundary.tryClone(fCommandline, this);
        cmd.setClassname(AppletRunner.class.getName());
        cmd.addSysproperty(getProtocolHandler());
        cmd.createArgument().setValue(writeArguments(appletPluginArguments));
        Execute execute = new Execute(new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN));
        execute.setCommandline(cmd.getCommandline());
        execute.setAntRun(getProject());

        // propagate the environment here?
        LOG.info(cmd.describeCommand());
        return AppletRunnerStepBoundary.tryExecute(execute, this);
    }
View Full Code Here

            propsFile.delete();
            throw new BuildException("Error creating temporary properties "
                                     + "file.", e, getLocation());
        }

        Execute execute = new Execute(
            new JUnitLogStreamHandler(
                this,
                Project.MSG_INFO,
                Project.MSG_WARN),
            watchdog);
        execute.setCommandline(cmd.getCommandline());
        execute.setAntRun(getProject());
        if (dir != null) {
            execute.setWorkingDirectory(dir);
        }

        String[] environment = env.getVariables();
        if (environment != null) {
            for (int i = 0; i < environment.length; i++) {
                log("Setting environment variable: " + environment[i],
                    Project.MSG_VERBOSE);
            }
        }
        execute.setNewenvironment(newEnvironment);
        execute.setEnvironment(environment);

        log(cmd.describeCommand(), Project.MSG_VERBOSE);

        checkForkedPath(cmd);

        TestResultHolder result = new TestResultHolder();
        try {
            result.exitCode = execute.execute();
        } catch (IOException e) {
            throw new BuildException("Process fork failed.", e, getLocation());
        } finally {
            String vmCrashString = "unknown";
            BufferedReader br = null;
View Full Code Here

    protected ByteArrayOutputStream errorstream = null;

    public int execute( Commandline cmd ) throws BuildException
    {
        createStreamHandler();
        Execute exe = new Execute(streamhandler, null);
        exe.setAntRun(project);

        exe.setWorkingDirectory(buildDir);

        exe.setCommandline(cmd.getCommandline());
        int result=0;
        try {
            result=exe.execute();
        } catch (IOException e) {
            throw new BuildException(e, location);
        }
        return result;
    }
View Full Code Here

                }
                commandline.createArgument().setValue(f.getPath());
            }
        }

        Execute execute = new Execute(new LogStreamHandler(this,
            Project.MSG_INFO, Project.MSG_WARN), watchdog);
        execute.setCommandline(commandline.getCommandline());
        if (getDir() != null) {
            execute.setWorkingDirectory(getDir());
            execute.setAntRun(getProject());
        }

        if (getOutputFile() != null) {
            log("Output to be stored in " + getOutputFile().getPath());
        }
        log(commandline.describeCommand(), Project.MSG_VERBOSE);
        try {
            return execute.execute();
        } catch (IOException e) {
            throw new BuildException("Process fork failed.", e, getLocation());
        }
    }
View Full Code Here

                errorstream = new LogOutputStream(this, Project.MSG_DEBUG);
            }
            streamhandler = new PumpStreamHandler(outputstream, errorstream);
        }

        Execute exe = getExecute(toExecute, streamhandler);
        try {
            log("Building the RPM based on the " + specFile + " file");
            int returncode = exe.execute();
            if (Execute.isFailure(returncode)) {
                String msg = "'" + toExecute.getExecutable()
                    + "' failed with exit code " + returncode;
                if (failOnError) {
                    throw new BuildException(msg);
View Full Code Here

TOP

Related Classes of org.apache.tools.ant.taskdefs.Execute

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.