Package org.apache.commons.exec

Examples of org.apache.commons.exec.CommandLine


                    throw new MojoExecutionException( "Could not make working directory: '"
                        + workingDirectory.getAbsolutePath() + "'" );
                }
            }

            CommandLine commandLine = getExecutablePath( enviro, workingDirectory );

            Executor exec = new DefaultExecutor();

            String[] args = new String[commandArguments.size()];
            for ( int i = 0; i < commandArguments.size(); i++ )
            {
                args[i] = (String) commandArguments.get( i );
            }

            commandLine.addArguments( args, false );

            exec.setWorkingDirectory( workingDirectory );

            fillSuccessCodes(exec);
           
View Full Code Here


        if ( exec == null )
        {
            exec = executable;
        }

        CommandLine toRet;
        if ( OS.isFamilyWindows() && exec.toLowerCase( Locale.getDefault() ).endsWith( ".bat" ) )
        {
            toRet = new CommandLine( "cmd" );
            toRet.addArgument( "/c" );
            toRet.addArgument( exec );
        }
        else
        {
            toRet = new CommandLine( exec );
        }

        return toRet;
    }
View Full Code Here

            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug(BUNDLE.get("INGEST_CONVERSION_COMMAND"), command);
            }

            final DefaultExecuteResultHandler handler = new DefaultExecuteResultHandler();
            final CommandLine cmdLine = CommandLine.parse(command);
            final DefaultExecutor executor = new DefaultExecutor();
            final ExecuteWatchdog watchdog = new ExecuteWatchdog(60000 * 10);
            final ByteArrayOutputStream error = new ByteArrayOutputStream();
            final ByteArrayOutputStream stdOut = new ByteArrayOutputStream();
            final Map<String, String> environment = EnvironmentUtils.getProcEnvironment();
View Full Code Here

            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug(BUNDLE.get("INGEST_CONVERSION_COMMAND"), command);
            }

            final DefaultExecuteResultHandler handler = new DefaultExecuteResultHandler();
            final CommandLine cmdLine = CommandLine.parse(command);
            final DefaultExecutor executor = new DefaultExecutor();
            final ExecuteWatchdog watchdog = new ExecuteWatchdog(60000 * 10);
            final ByteArrayOutputStream error = new ByteArrayOutputStream();
            final ByteArrayOutputStream stdOut = new ByteArrayOutputStream();
            final Map<String, String> environment = EnvironmentUtils.getProcEnvironment();
View Full Code Here

     *
     */
    private String[] parseParams(String line) {
        //JENKINS-24870 CommandLine.getExecutable tries to fix file separators, so if the first param contains slashes, it can cause problems
        //Adding some placeholder instead of executable
        CommandLine cmdLine = CommandLine.parse("executable_placeholder " + line)
        String[] parsedArgs = cmdLine.getArguments();
        String[] args = new String[parsedArgs.length];
        if(parsedArgs.length > 0) {
            System.arraycopy(parsedArgs, 0, args, 0, parsedArgs.length);
        }
        return args;
View Full Code Here

    logger.error("Stage group " + stageGroup.getName()
        + " has failed and cannot be restarted. ");
  }

  public void printJavaVersion() {
    CommandLine cmdLine = new CommandLine("java");
    cmdLine.addArgument("-version");
    DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
    Executor executor = new DefaultExecutor();
    try {
      executor.execute(cmdLine, resultHandler);
    } catch (ExecuteException e) {
View Full Code Here

   * Launches this stage and waits for process termination.
   *
   * @return true if the stage was killed by a call to the destroy()-method. false otherwise.
   */
  private boolean runGroup() {
    CommandLine cmdLine = new CommandLine(java);
    cmdLine.addArgument(jvmParameters, false);
    cmdLine.addArgument("-cp");
    cmdLine.addArgument("${classpath}", false);
    cmdLine.addArgument(GroupStarter.class.getCanonicalName());
    cmdLine.addArgument(stageGroup.getName());
    cmdLine.addArgument("localhost");
    cmdLine.addArgument("" + pipelinePort);
    cmdLine.addArgument("" + performanceLogging);
    cmdLine.addArgument("" + loggingPort);
    cmdLine.addArgument(startupArgsString);

    HashMap<String, Object> map = new HashMap<String, Object>();

    map.put("classpath", getClassPath());

    cmdLine.setSubstitutionMap(map);
    logger.info("Launching with command " + cmdLine.toString());

    CommandLauncher cl = CommandLauncherFactory.createVMLauncher();

    int exitValue = 0;

View Full Code Here

                    throw new MojoExecutionException( "Could not make working directory: '"
                        + workingDirectory.getAbsolutePath() + "'" );
                }
            }

            CommandLine commandLine = getExecutablePath( enviro, workingDirectory );

            Executor exec = new DefaultExecutor();

            String[] args = new String[commandArguments.size()];
            for ( int i = 0; i < commandArguments.size(); i++ )
            {
                args[i] = (String) commandArguments.get( i );
            }

            commandLine.addArguments( args, false );

            exec.setWorkingDirectory( workingDirectory );

            fillSuccessCodes(exec);
           
View Full Code Here

        if ( exec == null )
        {
            exec = executable;
        }

        CommandLine toRet;
        if ( OS.isFamilyWindows() && exec.toLowerCase( Locale.getDefault() ).endsWith( ".bat" ) )
        {
            toRet = new CommandLine( "cmd" );
            toRet.addArgument( "/c" );
            toRet.addArgument( exec );
        }
        else
        {
            toRet = new CommandLine( exec );
        }

        return toRet;
    }
View Full Code Here

        String classpath = manifestClasspath(sourceDirectory, outputDirectory, compileClasspathElements);

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

        if (ExecutionMode.INTERACTIVE == executionMode && SystemUtils.IS_OS_WINDOWS && spawnInteractiveConsoleOnWindows) {
            Scanner sc = new Scanner(windowsConsole);
            Pattern pattern = Pattern.compile("\"[^\"]*\"|'[^']*'|[\\w'/]+");
            cl = new CommandLine(sc.findInLine(pattern));
            String param;
            while ((param = sc.findInLine(pattern)) != null) {
                cl.addArgument(param);
            }
            cl.addArgument(javaExecutable);
        } else {
            cl = new CommandLine(javaExecutable);
        }

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

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

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

        cl.addArguments(clojureOptions, false);

        cl.addArgument("-jar");
  File jar;
        if (prependClasses != null && prependClasses.size() > 0) {
            jar = createJar(classpath, prependClasses.get(0));
            cl.addArgument(jar.getAbsolutePath(), false);
      List<String> allButFirst = prependClasses.subList(1, prependClasses.size());
            cl.addArguments(allButFirst.toArray(new String[allButFirst.size()]));
      cl.addArgument(mainClass);
        } else {
            jar = createJar(classpath, mainClass);
            cl.addArgument(jar.getAbsolutePath(), false);
  }


        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

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.