Java Code Examples for com.intellij.execution.configurations.GeneralCommandLine#setExePath()

The following examples show how to use com.intellij.execution.configurations.GeneralCommandLine#setExePath() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CabalJspInterface.java    From intellij-haskforce with Apache License 2.0 6 votes vote down vote up
private GeneralCommandLine getCommandLine(String command, String... args) throws IOException, ExecutionException {
    GeneralCommandLine commandLine = new GeneralCommandLine();
    commandLine.setWorkDirectory(myCabalFile.getParentFile().getCanonicalPath());
    commandLine.setExePath(myBuildOptions.myCabalPath);
    ParametersList parametersList = commandLine.getParametersList();
    parametersList.add("--with-ghc=" + myBuildOptions.myGhcPath);
    parametersList.add(command);
    if (command.equals("install") || command.equals("configure")) {
        if (myBuildOptions.myEnableTests) {
            parametersList.add("--enable-tests");
        }
        if (!myBuildOptions.myProfilingBuild) {
            parametersList.add("--disable-library-profiling");
        }
    }
    parametersList.addAll(args);
    commandLine.setRedirectErrorStream(true);
    return commandLine;
}
 
Example 2
Source File: LoginSsoCallbackHandler.java    From p4ic4idea with Apache License 2.0 6 votes vote down vote up
@NotNull
private GeneralCommandLine createCommandLine() {
    GeneralCommandLine ret = new GeneralCommandLine();
    if (SystemInfo.isWindows) {
        ret.setExePath(ExecUtil.getWindowsShellName());
        ret.addParameters("/c",
                GeneralCommandLine.inescapableQuote(loginSsoCmd));
    } else if (SystemInfo.isMac) {
        ret.setExePath(ExecUtil.getOpenCommandPath());
        ret.addParameters("-a", loginSsoCmd);
    } else {
        ret.setExePath("/bin/sh");
        ret.addParameters("-c", loginSsoCmd);
    }
    return ret;
}
 
Example 3
Source File: NodeRunner.java    From vue-for-idea with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @param cwd working directory
 * @param node node interpreter path
 * @param exe node executable to run
 * @return command line to sdk
 */
@NotNull
public static GeneralCommandLine createCommandLine(@NotNull String cwd, String node, String exe) {
    GeneralCommandLine commandLine = new GeneralCommandLine();
    if (!new File(cwd).exists()) {
        throw new IllegalArgumentException("cwd: "+cwd +" doesn't exist");
    }
    if (!new File(exe).exists()) {
        throw new IllegalArgumentException("exe: "+exe +" doesn't exist");

    }
    commandLine.setWorkDirectory(cwd);
    if (SystemInfo.isWindows) {
        commandLine.setExePath(exe);
    } else {
        if (!new File(node).exists()) {
            throw new IllegalArgumentException("path doesn't exist");
        }
        commandLine.setExePath(node);
        commandLine.addParameter(exe);
    }
    return commandLine;
}
 
Example 4
Source File: BuckCommandHandler.java    From Buck-IntelliJ-Plugin with Apache License 2.0 6 votes vote down vote up
/**
 * @param project   a project
 * @param directory a process directory
 * @param command   a command to execute (if empty string, the parameter is ignored)
 */
public BuckCommandHandler(
    Project project,
    File directory,
    BuckCommand command) {

  String buckExecutable = BuckSettingsProvider.getInstance().getState().buckExecutable;

  mProject = project;
  mCommand = command;
  mCommandLine = new GeneralCommandLine();
  mCommandLine.setExePath(buckExecutable);
  mWorkingDirectory = directory;
  mCommandLine.withWorkDirectory(mWorkingDirectory);
  mCommandLine.addParameter(command.name());
}
 
Example 5
Source File: HLint.java    From intellij-haskforce with Apache License 2.0 6 votes vote down vote up
/**
 * Runs hlintProg with parameters if hlintProg can be executed.
 */
@NotNull
public static Either<ExecError, String> runHlint(HaskellToolsConsole.Curried toolConsole,
                                                  @NotNull String workingDirectory,
                                                  @NotNull String hlintProg,
                                                  @NotNull String hlintFlags,
                                                  @Nullable String fileContents,
                                                  @NotNull String... params) {
    GeneralCommandLine commandLine = new GeneralCommandLine();
    commandLine.setWorkDirectory(workingDirectory);
    commandLine.setExePath(hlintProg);
    ParametersList parametersList = commandLine.getParametersList();
    // Required so that hlint won't report a non-zero exit status for lint issues.
    // Otherwise, ExecUtil.readCommandLine will return an error.
    parametersList.add("--no-exit-code");
    parametersList.addParametersString(hlintFlags);
    parametersList.addAll(params);
    toolConsole.writeInput("Using working directory: " + workingDirectory);
    toolConsole.writeInput(commandLine.getCommandLineString());
    return ExecUtil.readCommandLine(commandLine, fileContents);
}
 
Example 6
Source File: PantsCompileOptionsExecutor.java    From intellij-pants-plugin with Apache License 2.0 6 votes vote down vote up
@NotNull
private static String loadProjectStructureFromScript(
  @NotNull String scriptPath,
  @NotNull Consumer<String> statusConsumer,
  @Nullable ProcessAdapter processAdapter
) throws IOException, ExecutionException {
  final GeneralCommandLine commandLine = PantsUtil.defaultCommandLine(scriptPath);
  commandLine.setExePath(scriptPath);
  statusConsumer.consume("Executing " + PathUtil.getFileName(scriptPath));
  final ProcessOutput processOutput = PantsUtil.getCmdOutput(commandLine, processAdapter);
  if (processOutput.checkSuccess(LOG)) {
    return processOutput.getStdout();
  }
  else {
    throw new PantsExecutionException("Failed to update the project!", scriptPath, processOutput);
  }
}
 
Example 7
Source File: RedisConsoleRunner.java    From nosql4idea with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
protected Process createProcess() throws ExecutionException {

    NoSqlConfiguration noSqlConfiguration = NoSqlConfiguration.getInstance(getProject());
    String shellPath = noSqlConfiguration.getShellPath(DatabaseVendor.REDIS);
    final GeneralCommandLine commandLine = new GeneralCommandLine();
    commandLine.setExePath(shellPath);

    commandLine.addParameter("-n");
    commandLine.addParameter(database.getName());

    String shellWorkingDir = serverConfiguration.getShellWorkingDir();
    if (StringUtils.isNotBlank(shellWorkingDir)) {
        commandLine.setWorkDirectory(shellWorkingDir);
    }

    String shellArgumentsLine = serverConfiguration.getShellArgumentsLine();
    if (StringUtils.isNotBlank(shellArgumentsLine)) {
        commandLine.addParameters(shellArgumentsLine.split(" "));
    }

    return commandLine.createProcess();
}
 
Example 8
Source File: FlutterCommand.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Creates the command line to run.
 * <p>
 * If a project is supplied, it will be used to determine the ANDROID_HOME variable for the subprocess.
 */
@NotNull
public GeneralCommandLine createGeneralCommandLine(@Nullable Project project) {
  final GeneralCommandLine line = new GeneralCommandLine();
  line.setCharset(CharsetToolkit.UTF8_CHARSET);
  line.withEnvironment(FlutterSdkUtil.FLUTTER_HOST_ENV, FlutterSdkUtil.getFlutterHostEnvValue());
  final String androidHome = IntelliJAndroidSdk.chooseAndroidHome(project, false);
  if (androidHome != null) {
    line.withEnvironment("ANDROID_HOME", androidHome);
  }
  line.setExePath(FileUtil.toSystemDependentName(sdk.getHomePath() + "/bin/" + FlutterSdkUtil.flutterScriptName()));
  if (workDir != null) {
    line.setWorkDirectory(workDir.getPath());
  }
  if (!isDoctorCommand()) {
    line.addParameter("--no-color");
  }
  line.addParameters(type.subCommand);
  line.addParameters(args);
  return line;
}
 
Example 9
Source File: GaugeCommandLine.java    From Intellij-Plugin with Apache License 2.0 6 votes vote down vote up
public static GeneralCommandLine getInstance(Module module, Project project) {
    GeneralCommandLine commandLine = new GeneralCommandLine();
    try {
        GaugeSettingsModel settings = GaugeUtil.getGaugeSettings();
        commandLine.setExePath(settings.getGaugePath());
        Map<String, String> environment = commandLine.getEnvironment();
        environment.put(Constants.GAUGE_HOME, settings.getHomePath());
    } catch (GaugeNotFoundException e) {
        commandLine.setExePath(Constants.GAUGE);
    } finally {
        commandLine.setWorkDirectory(project.getBasePath());
        if (module != null)
            commandLine.setWorkDirectory(GaugeUtil.moduleDir(module));
        return commandLine;
    }
}
 
Example 10
Source File: FreelineUtil.java    From freeline with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void build(Project project) {
    GeneralCommandLine commandLine = new GeneralCommandLine();
    commandLine.setWorkDirectory(project.getBasePath());
    commandLine.setExePath("python");
    commandLine.addParameter("freeline.py");
    // debug
    commandLine.addParameter("-d");

    // commands process
    try {
        processCommandline(project, commandLine);
    } catch (ExecutionException e) {
        e.printStackTrace();
    }
}
 
Example 11
Source File: PdbStrExe.java    From teamcity-symbol-server with Apache License 2.0 5 votes vote down vote up
public ExecResult doCommand(final PdbStrExeCommands cmd, final File pdbFile, final File inputStreamFile, final String streamName){
  final GeneralCommandLine commandLine = new GeneralCommandLine();
  commandLine.setWorkDirectory(myPath.getParent());
  commandLine.setExePath(myPath.getPath());
  commandLine.addParameter(cmd.getCmdSwitch());
  commandLine.addParameter(String.format("%s:%s", PATH_TO_PDB_FILE_SWITCH, pdbFile.getAbsolutePath()));
  commandLine.addParameter(String.format("%s:%s", PATH_TO_INPUT_FILE_SWITCH, inputStreamFile.getAbsolutePath()));
  commandLine.addParameter(STREAM_NAME_SWITCH + ":" + streamName);
  return SimpleCommandLineProcessRunner.runCommand(commandLine, null);
}
 
Example 12
Source File: BuckWSServerPortUtils.java    From buck with Apache License 2.0 5 votes vote down vote up
/** Returns the port number of Buck's HTTP server, if it can be determined. */
public static int getPort(Project project, String path)
    throws NumberFormatException, IOException, ExecutionException {
  String exec = BuckExecutableSettingsProvider.getInstance(project).resolveBuckExecutable();

  if (Strings.isNullOrEmpty(exec)) {
    throw new RuntimeException("Buck executable is not defined in settings.");
  }

  GeneralCommandLine commandLine = new GeneralCommandLine();
  commandLine.setExePath(exec);
  commandLine.withWorkDirectory(path);
  commandLine.withEnvironment(EnvironmentUtil.getEnvironmentMap());
  commandLine.addParameter("server");
  commandLine.addParameter("status");
  commandLine.addParameter("--reuse-current-config");
  commandLine.addParameter("--http-port");
  commandLine.setRedirectErrorStream(true);

  Process p = commandLine.createProcess();
  BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));

  String line;
  while ((line = reader.readLine()) != null) {
    if (line.startsWith(SEARCH_FOR)) {
      return Integer.parseInt(line.substring(SEARCH_FOR.length()));
    }
  }
  throw new RuntimeException(
      "Configured buck executable did not report a valid port string,"
          + " ensure "
          + commandLine.getCommandLineString()
          + " can be run from "
          + path);
}
 
Example 13
Source File: PantsUtil.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
@NotNull
public static GeneralCommandLine defaultCommandLine(@NotNull File pantsExecutable) {
  final GeneralCommandLine commandLine = new GeneralCommandLine();
  final String pantsExecutablePath = StringUtil.notNullize(
    System.getProperty("pants.executable.path"),
    pantsExecutable.getAbsolutePath()
  );
  commandLine.setExePath(pantsExecutablePath);
  final String workingDir = pantsExecutable.getParentFile().getAbsolutePath();
  return commandLine.withWorkDirectory(workingDir);
}
 
Example 14
Source File: JetSymbolsExe.java    From teamcity-symbol-server with Apache License 2.0 5 votes vote down vote up
public Collection<File> getReferencedSourceFiles(File symbolsFile, BuildProgressLogger buildLogger) {
  final GeneralCommandLine commandLine = new GeneralCommandLine();
  commandLine.setExePath(myExePath.getPath());
  commandLine.addParameter(LIST_SOURCES_CMD);
  commandLine.addParameter(symbolsFile.getAbsolutePath());

  final ExecResult execResult = executeCommandLine(commandLine, buildLogger);
  if (execResult.getExitCode() == 0) {
    return CollectionsUtil.convertAndFilterNulls(Arrays.asList(execResult.getOutLines()), File::new);
  } else {
    return Collections.emptyList();
  }
}
 
Example 15
Source File: JetSymbolsExe.java    From teamcity-symbol-server with Apache License 2.0 5 votes vote down vote up
public PdbType getPdbType(File symbolsFile, BuildProgressLogger buildLogger) {
  final GeneralCommandLine commandLine = new GeneralCommandLine();
  commandLine.setExePath(myExePath.getPath());
  commandLine.addParameter(GET_PDB_TYPE_CMD);
  commandLine.addParameter(symbolsFile.getAbsolutePath());

  final ExecResult execResult = executeCommandLine(commandLine, buildLogger);
  if (execResult.getExitCode() == 0) {
    return parsePdbType(execResult.getOutLines(), buildLogger);
  } else {
    buildLogger.error("Cannot parse PDB type.");
    return PdbType.Undefined;
  }
}
 
Example 16
Source File: FastpassUtils.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
@NotNull
public static GeneralCommandLine makeFastpassCommand(Project project, @NotNull Collection<String> amendPart) throws IOException {
  GeneralCommandLine commandLine = PantsUtil.defaultCommandLine(project);
  String coursier = FastpassUtils.coursierPath().toString();
  commandLine.setExePath(coursier);
  commandLine.addParameters(coursierPart());
  commandLine.addParameters(new ArrayList<>(amendPart));
  return commandLine;
}
 
Example 17
Source File: ProcessGroupUtil.java    From intellij with Apache License 2.0 5 votes vote down vote up
public static GeneralCommandLine newProcessGroupFor(GeneralCommandLine commandLine) {
  if (!useProcessGroup()) {
    return commandLine;
  }
  String executable = commandLine.getExePath();
  commandLine.getParametersList().prependAll("--wait", executable);
  commandLine.setExePath(SETSID_PATH);
  return commandLine;
}
 
Example 18
Source File: DeviceDaemon.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private GeneralCommandLine toCommandLine() {
  final GeneralCommandLine result = new GeneralCommandLine().withWorkDirectory(workDir);
  result.setCharset(CharsetToolkit.UTF8_CHARSET);
  result.setExePath(FileUtil.toSystemDependentName(command));
  result.withEnvironment(FlutterSdkUtil.FLUTTER_HOST_ENV, FlutterSdkUtil.getFlutterHostEnvValue());
  if (androidHome != null) {
    result.withEnvironment("ANDROID_HOME", androidHome);
  }
  for (String param : parameters) {
    result.addParameter(param);
  }
  return result;
}
 
Example 19
Source File: DevToolsManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Gets the process handler that will start DevTools in bazel.
 */
@Nullable
private OSProcessHandler getProcessHandlerForBazel() {
  final WorkspaceCache workspaceCache = WorkspaceCache.getInstance(project);
  if (!workspaceCache.isBazel()) {
    return null;
  }
  final Workspace workspace = workspaceCache.get();
  assert (workspace != null);
  if (workspace.getDevtoolsScript() == null) {
    return null;
  }

  final GeneralCommandLine commandLine = new GeneralCommandLine().withWorkDirectory(workspace.getRoot().getPath());
  commandLine.setExePath(FileUtil.toSystemDependentName(workspace.getRoot().getPath() + "/" + workspace.getLaunchScript()));
  commandLine.setCharset(CharsetToolkit.UTF8_CHARSET);
  commandLine.addParameters(workspace.getDevtoolsScript(), "--", "--machine", "--port=0");
  OSProcessHandler handler;

  try {
    handler = new MostlySilentOsProcessHandler(commandLine);
  }
  catch (ExecutionException e) {
    FlutterUtils.warn(LOG, e);
    handler = null;
  }

  if (handler != null) {
    FlutterConsoles.displayProcessLater(handler, project, null, handler::startNotify);
  }

  return handler;
}
 
Example 20
Source File: RNUtil.java    From react-native-console with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void runGradleCI(Project project, String... params) {
        String path = RNPathUtil.getRNProjectPath(project);
        String gradleLocation = RNPathUtil.getAndroidProjectPath(path);
        if (gradleLocation == null) {
            NotificationUtils.gradleFileNotFound();
        } else {
            GeneralCommandLine commandLine = new GeneralCommandLine();
//    ExecutionEnvironment environment = getEnvironment();
            commandLine.setWorkDirectory(gradleLocation);
            commandLine.setExePath("." + File.separator + "gradlew");
            commandLine.addParameters(params);

//            try {
////            Process process = commandLine.createProcess();
//                OSProcessHandler processHandler = new KillableColoredProcessHandler(commandLine);
//                RunnerUtil.showHelperProcessRunContent("Update AAR", processHandler, project, DefaultRunExecutor.getRunExecutorInstance());
//                // Run
//                processHandler.startNotify();
//            } catch (ExecutionException e) {
//                e.printStackTrace();
//                NotificationUtils.errorNotification("Can't execute command: " + e.getMessage());
//            }

            // commands process
            try {
                processCommandline(project, commandLine);
            } catch (ExecutionException e) {
                e.printStackTrace();
            }
        }
    }