Package org.apache.commons.exec

Examples of org.apache.commons.exec.CommandLine


        cp = cp.replaceAll("\\s", "\\ ");

        final String javaExecutable = getJavaExecutable();
        getLog().debug("Java exectuable used:  " + javaExecutable);
        getLog().debug("Clojure classpath: " + cp);
        CommandLine cl = null;

        if (ExecutionMode.INTERACTIVE == executionMode && SystemUtils.IS_OS_WINDOWS && spawnInteractiveConsoleOnWindows) {
            cl = new CommandLine("cmd");
            cl.addArgument("/c");
            cl.addArgument("start");
            cl.addArgument(javaExecutable);
        } else {
            cl = new CommandLine(javaExecutable);
        }

        if (vmargs != null) {
            cl.addArguments(vmargs, false);
        }

        cl.addArgument("-cp");
        cl.addArgument(cp, false);
        cl.addArgument("-Dclojure.compile.path=" + escapeFilePath(outputDirectory), false);

        if (warnOnReflection) cl.addArgument("-Dclojure.compile.warn-on-reflection=true");

        cl.addArguments(clojureOptions, false);

        if (prependClasses != null) {
            cl.addArguments(prependClasses.toArray(new String[prependClasses.size()]));
        }

        cl.addArgument(mainClass);

        if (clojureArgs != null) {
            cl.addArguments(clojureArgs, false);
        }

        getLog().debug("Command line: " + cl.toString());

        Executor exec = new DefaultExecutor();
        Map<String, String> env = new HashMap<String, String>(System.getenv());
//        env.put("path", ";");
//        env.put("path", System.getProperty("java.home"));
View Full Code Here


        final String vmOptions = System.getProperty("jar.executor.vm.options");
        final Executor e = new DefaultExecutor();
        if (this.workingDirectory != null) {
            e.setWorkingDirectory(this.workingDirectory);
        }
        final CommandLine cl = new CommandLine(javaExecutable);
        if (vmOptions != null && vmOptions.length() > 0) {
            // TODO: this will fail if one of the vm options as a quoted value with a space in it, but this is
            // not the case for common usage patterns
            for (String option : StringUtils.split(vmOptions, " ")) {
                cl.addArgument(option);
            }
        }
        cl.addArgument("-jar");
        cl.addArgument(jarToExecute.getAbsolutePath());
        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

          if ( arguments != null ) {
            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 += " " + arguments;
          }

          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

    extends AbstractMojo
{
    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

    }

    private void packageApplication() throws MojoExecutionException {
        String line = getPlay2().getAbsolutePath();

        CommandLine cmdLine = CommandLine.parse(line);
        cmdLine.addArgument("package");
        DefaultExecutor executor = new DefaultExecutor();

        if (timeout > 0) {
            ExecuteWatchdog watchdog = new ExecuteWatchdog(timeout);
            executor.setWatchdog(watchdog);
View Full Code Here

    }

    private void packageDistribution() throws MojoExecutionException {
        String line = getPlay2().getAbsolutePath();

        CommandLine cmdLine = CommandLine.parse(line);
        cmdLine.addArgument("dist");
        DefaultExecutor executor = new DefaultExecutor();

        if (timeout > 0) {
            ExecuteWatchdog watchdog = new ExecuteWatchdog(timeout);
            executor.setWatchdog(watchdog);
View Full Code Here

    public void execute() throws MojoExecutionException {

        String line = getPlay2().getAbsolutePath();

        CommandLine cmdLine = CommandLine.parse(line);

        cmdLine.addArgument("debug");
        cmdLine.addArguments(getPlay2SystemPropertiesArguments(), false);
        cmdLine.addArgument("run");
        DefaultExecutor executor = new DefaultExecutor();

        // As where not linked to a project, we can't set the working directory.
        // So it will use the directory where mvn was launched.
View Full Code Here

    public void execute()
            throws MojoExecutionException {

        String line = getPlay2().getAbsolutePath();

        CommandLine cmdLine = CommandLine.parse(line);
        cmdLine.addArguments(getPlay2SystemPropertiesArguments(), false);
        cmdLine.addArgument("run");
        DefaultExecutor executor = new DefaultExecutor();

        // As where not linked to a project, we can't set the working directory.
        // So it will use the directory where mvn was launched.
View Full Code Here

    public void execute()
            throws MojoExecutionException {

        String line = getPlay2().getAbsolutePath();

        CommandLine cmdLine = CommandLine.parse(line);
        cmdLine.addArgument("compile");
        DefaultExecutor executor = new DefaultExecutor();

        if (timeout > 0) {
            ExecuteWatchdog watchdog = new ExecuteWatchdog(timeout);
            executor.setWatchdog(watchdog);
View Full Code Here

TOP

Related Classes of org.apache.commons.exec.CommandLine

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.