/**
  * Creates a number of parameter groups in the command line: GROUP_EXE_OPTIONS, GROUP_DEBUGGER,
  * GROUP_SCRIPT. These are necessary for command line patchers to work properly.
  *
  * @param commandLine
  */
 public static void createStandardGroups(GeneralCommandLine commandLine) {
   ParametersList params = commandLine.getParametersList();
   params.addParamsGroup(GROUP_EXE_OPTIONS);
   params.addParamsGroup(GROUP_DEBUGGER);
   params.addParamsGroup(GROUP_PROFILER);
   params.addParamsGroup(GROUP_COVERAGE);
   params.addParamsGroup(GROUP_SCRIPT);
 }
 /**
  * Returns string representation of this command line.<br>
  * Warning: resulting string is not OS-dependent - <b>do not</b> use it for executing this command
  * line.
  *
  * @param exeName use this executable name instead of given by {@link #setExePath(String)}
  * @return single-string representation of this command line.
  */
 public String getCommandLineString(@Nullable final String exeName) {
   final List<String> commands = new ArrayList<String>();
   if (exeName != null) {
     commands.add(exeName);
   } else if (myExePath != null) {
     commands.add(myExePath);
   } else {
     commands.add("<null>");
   }
   commands.addAll(myProgramParams.getList());
   return ParametersList.join(commands);
 }
 @Override
 public ParametersList clone() {
   try {
     final ParametersList clone = (ParametersList) super.clone();
     clone.myParameters = new ArrayList<String>(myParameters);
     clone.myGroups = new ArrayList<ParamsGroup>(myGroups.size() + 1);
     for (ParamsGroup group : myGroups) {
       clone.myGroups.add(group.clone());
     }
     return clone;
   } catch (CloneNotSupportedException e) {
     LOG.error(e);
     return null;
   }
 }
  public Process createProcess() throws ExecutionException {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Executing [" + getCommandLineString() + "]");
    }

    List<String> commands;
    try {
      checkWorkingDirectory();

      if (StringUtil.isEmptyOrSpaces(myExePath)) {
        throw new ExecutionException(
            IdeBundle.message("run.configuration.error.executable.not.specified"));
      }

      commands = CommandLineUtil.toCommandLine(myExePath, myProgramParams.getList());
    } catch (ExecutionException e) {
      LOG.warn(e);
      throw e;
    }

    try {
      ProcessBuilder builder = new ProcessBuilder(commands);
      setupEnvironment(builder.environment());
      builder.directory(myWorkDirectory);
      builder.redirectErrorStream(myRedirectErrorStream);
      return builder.start();
    } catch (IOException e) {
      LOG.warn(e);
      throw new ProcessNotCreatedException(e.getMessage(), e, this);
    }
  }
 /**
  * Prepares command (quotes and escapes all arguments) and returns it as a newline-separated list
  * (suitable e.g. for passing in an environment variable).
  *
  * @return command as a newline-separated list.
  */
 @NotNull
 public String getPreparedCommandLine() {
   String exePath = myExePath != null ? myExePath : "";
   return StringUtil.join(CommandLineUtil.toCommandLine(exePath, myProgramParams.getList()), "\n");
 }
 public void addParameter(@NotNull @NonNls final String parameter) {
   myProgramParams.add(parameter);
 }