Package org.apache.commons.exec

Examples of org.apache.commons.exec.DefaultExecutor.execute()


        executor.setStreamHandler(handler);

        CommandLine cl = toCommandLine(command);

        try {
            int exitValue = executor.execute(cl);
            // if the size is zero, we have no output, so construct the result
            // with null (required by ExecResult)
            InputStream stdout = out.size() == 0 ? null : new ByteArrayInputStream(out.toByteArray());
            InputStream stderr = err.size() == 0 ? null : new ByteArrayInputStream(err.toByteArray());
            ExecResult result = new ExecResult(command, stdout, stderr, exitValue);
View Full Code Here


    protected BufferedReader runProcEnvCommand() throws IOException {
        final ByteArrayOutputStream out = new ByteArrayOutputStream();
        final Executor exe = new DefaultExecutor();
        exe.setStreamHandler(new PumpStreamHandler(out));
        // ignore the exit value - Just try to use what we got
        exe.execute(getProcEnvCommand());
        return new BufferedReader(new StringReader(toString(out)));
    }

    /**
     * Determine the OS specific command line to get a list of environment
View Full Code Here

        exec.setStreamHandler(handler);
        exec.setWorkingDirectory(getWorkingDirectory());

        int status;
        try {
            status = exec.execute(cl, env);
        } catch (ExecuteException e) {
            status = e.getExitValue();
        } catch (IOException e) {
            status = 1;
        }
View Full Code Here

        cl.addArgument("-p");
        cl.addArgument(String.valueOf(serverPort));
        log.info("Executing " + cl);
        e.setStreamHandler(new PumpStreamHandler());
        e.setProcessDestroyer(new ShutdownHookProcessDestroyer());
        e.execute(cl, h);
    }

}
View Full Code Here

            line += " " + arguments;
          }

          CommandLine commandLine = CommandLine.parse(line);
          DefaultExecutor executor = new DefaultExecutor();
          int exitValue = executor.execute(commandLine);
         
          if ( exitValue != 0 ) {
              throw new MojoExecutionException( "Problem executing light, return code " + exitValue );
          }
        
View Full Code Here

          line += " " + paths;
         
          CommandLine commandLine = CommandLine.parse(line);
          DefaultExecutor executor = new DefaultExecutor();
          int exitValue = executor.execute(commandLine);
         
          if ( exitValue != 0 ) {
              throw new MojoExecutionException( "Problem executing candle, return code " + exitValue );
          }
        
View Full Code Here

    protected int executeCommandLine( String line )
        throws ExecuteException, IOException
    {
        CommandLine commandLine = CommandLine.parse( line );
        DefaultExecutor executor = new DefaultExecutor();
        return executor.execute( commandLine );
    }

}
View Full Code Here

        }

        executor.setWorkingDirectory(project.getBasedir());
        executor.setExitValue(0);
        try {
            executor.execute(cmdLine, getEnvironment());
        } catch (IOException e) {
            throw new MojoExecutionException("Error during packaging", e);
        }
    }
View Full Code Here

        }

        executor.setWorkingDirectory(project.getBasedir());
        executor.setExitValue(0);
        try {
            executor.execute(cmdLine, getEnvironment());
        } catch (IOException e) {
            throw new MojoExecutionException("Error during distribution creation", e);
        }
    }
View Full Code Here

        }

        executor.setWorkingDirectory(project.getBasedir());
        executor.setExitValue(0);
        try {
            executor.execute(cmdLine, getEnvironment());
        } catch (IOException e) {
            throw new MojoExecutionException("Error during cleanup", e);
        }
       
        // Also delete the dist directory
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.