Package com.intellij.execution.configurations

Examples of com.intellij.execution.configurations.GeneralCommandLine


        ProcessTerminatedListener.attach(osProcessHandler);
        return osProcessHandler;
    }

    private GeneralCommandLine generateCommandLine() {
        GeneralCommandLine commandLine = new GeneralCommandLine();
        commandLine.setExePath(runConfiguration.getInterpreterPath());
        commandLine.getParametersList().addParametersString("/c");
        commandLine.getParametersList().addParametersString(runConfiguration.getInterpreterOptions());
        if (!StringUtil.isEmptyOrSpaces(runConfiguration.getScriptName())) {
            commandLine.addParameter(runConfiguration.getScriptName());
        }

        commandLine.getParametersList().addParametersString(runConfiguration.getScriptParameters());
        if (!StringUtil.isEmptyOrSpaces(runConfiguration.getWorkingDirectory())) {
            commandLine.setWorkDirectory(runConfiguration.getWorkingDirectory());
        }

        commandLine.setEnvParams(runConfiguration.getEnvs());
        commandLine.setPassParentEnvs(runConfiguration.isPassParentEnvs());
        return commandLine;
    }
View Full Code Here


        this.myParameters = parameters;
    }

    @Override
    protected OSProcessHandler startProcess() throws ExecutionException {
        GeneralCommandLine commandLine = new GeneralCommandLine();
        commandLine.setExePath(mySettings.leiningenPath);
        commandLine.addParameters(myParameters.getGoals());
        commandLine.setWorkDirectory(myParameters.getWorkingDirectory());
        return new ColoredProcessHandler(commandLine.createProcess(), commandLine.getCommandLineString(),
                EncodingManager.getInstance().getDefaultCharset());
    }
View Full Code Here

  }

  public static GeneralCommandLine getRebarCommandLine(@NotNull RebarRunConfigurationBase configuration) {
    Project project = configuration.getProject();
    RebarSettings rebarSettings = RebarSettings.getInstance(project);
    GeneralCommandLine commandLine = new GeneralCommandLine();

    commandLine.setWorkDirectory(getWorkingDirectory(configuration));
    commandLine.setExePath(rebarSettings.getRebarPath());

    List<String> split = ContainerUtil.list(configuration.getCommand().split("\\s+"));
    if (configuration.isSkipDependencies() && !split.contains("skip_deps=true")) {
      commandLine.addParameter("skip_deps=true");
    }
    commandLine.addParameters(split);

    return commandLine;
  }
View Full Code Here

                                               @NotNull String... arguments) throws ExecutionException {
    if (!new File(workDir).isDirectory() || !new File(exePath).canExecute()) {
      return new ProcessOutput();
    }

    GeneralCommandLine cmd = new GeneralCommandLine();
    cmd.setWorkDirectory(workDir);
    cmd.setExePath(exePath);
    cmd.addParameters(arguments);

    return execute(cmd, timeout);
  }
View Full Code Here

  @Override
  public void compile(CompileContext context, Chunk<Module> moduleChunk, VirtualFile[] files, OutputSink outputSink) {
    context.getProgressIndicator().pushState();
    context.getProgressIndicator().setText("Hardcore compile action...");

    GeneralCommandLine commandLine = new GeneralCommandLine();
    commandLine.setWorkDirectory(PathUtil.getParentPath(context.getProject().getProjectFilePath()));
    commandLine.setPassParentEnvironment(true);

    for (Module module : moduleChunk.getNodes()) {
      ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);

      for (VirtualFile sourceRoot : moduleRootManager.getSourceRoots()) {
        commandLine.addParameter("-I");
        String path = sourceRoot.getCanonicalPath();
        if (path != null) {
          commandLine.addParameter(path);
        }
      }

      VirtualFile outDir = context.getModuleOutputDirectory(module);
      if (outDir == null) {
        context.addMessage(CompilerMessageCategory.ERROR, "No output dir for module: " + module.getName(), null, -1, -1);
        return;
      }
      commandLine.setWorkDirectory(outDir.getCanonicalPath());

      for (VirtualFile o : files) {
        String canonicalPath = o.getCanonicalPath();
        if (canonicalPath == null) continue;
        commandLine.addParameter(canonicalPath);
      }

//      commandLine.addParameters("+warn_unused_vars", "+nowarn_shadow_vars", "+warn_unused_import");

      Sdk sdk = moduleRootManager.getSdk();

      if (sdk == null) {
        context.addMessage(CompilerMessageCategory.ERROR, "No SDK for module: " + module.getName(), null, -1, -1);
        return;
      }

      if (sdk.getSdkType() != ErlangSdkType.getInstance()) {
        context.addMessage(CompilerMessageCategory.ERROR, "Not a Erlang SDK for module: " + module.getName(), null, -1, -1);
        return;
      }

      String sdkHomePath = sdk.getHomePath();

      if (sdkHomePath == null) {
        context.addMessage(CompilerMessageCategory.ERROR, "No home path for Erlang SDK: " + sdk.getName(), null, -1, -1);
        return;
      }

      String erlc = FileUtil.toSystemDependentName(JpsErlangSdkType.getByteCodeCompilerExecutable(sdkHomePath).getAbsolutePath());

      commandLine.setExePath(erlc);

//      System.out.println(commandLine.getCommandLineString());

      ProcessOutput output = null;
      try {
        output = new CapturingProcessHandler(commandLine.createProcess(), Charset.defaultCharset(), commandLine.getCommandLineString()).runProcess();
      } catch (ExecutionException e) {
        context.addMessage(CompilerMessageCategory.ERROR, "process throw exception: " + e.getMessage(), null, -1, -1);
      }

      if (output != null) {
View Full Code Here

      }
    }

    String output = "";
    try {
      GeneralCommandLine which = new GeneralCommandLine("which");
      which.addParameter("rebar");
      output = ScriptRunnerUtil.getProcessOutput(which);
    } catch (Exception ignored) {
    }
    return output.trim();
  }
View Full Code Here

  private static void fetchDependencies(@NotNull final VirtualFile projectRoot, @NotNull final String rebarPath) {
    ProgressManager.getInstance().run(new Task.Modal(ProjectImportBuilder.getCurrentProject(), "Fetching dependencies", true) {
      public void run(@NotNull final ProgressIndicator indicator) {
        indicator.setIndeterminate(true);
        GeneralCommandLine commandLine = new GeneralCommandLine();
        commandLine.setExePath(rebarPath);
        commandLine.setWorkDirectory(projectRoot.getCanonicalPath());
        commandLine.addParameter("get-deps");
        try {
          OSProcessHandler handler = new OSProcessHandler(commandLine.createProcess(), commandLine.getPreparedCommandLine(Platform.current()));
          handler.addProcessListener(new ProcessAdapter() {
            @Override
            public void onTextAvailable(ProcessEvent event, Key outputType) {
              String text = event.getText();
              indicator.setText2(text);
View Full Code Here

  }

  @NotNull
  @Override
  protected ProcessHandler startProcess() throws ExecutionException {
    GeneralCommandLine commandLine = RebarRunningStateUtil.getRebarCommandLine(myConfiguration);
    return RebarRunningStateUtil.runRebar(myConfiguration.getProject(), commandLine);
  }
View Full Code Here

  }

  @NotNull
  @Override
  protected ProcessHandler startProcess() throws ExecutionException {
    GeneralCommandLine commandLine = RebarRunningStateUtil.getRebarCommandLine(myConfiguration);
    File reportsRoot = createEunitReportsEnvironment();

    addEnvParams(commandLine, reportsRoot);
    addConfigFileArgument(commandLine, reportsRoot);
View Full Code Here

    VirtualFile virtualFile = psiFile.getVirtualFile();
    if (virtualFile == null) return;

    final String groupId = e.getPresentation().getText();
    try {
      GeneralCommandLine commandLine = new GeneralCommandLine();
      String emacsPath = EmacsSettings.getInstance(project).getEmacsPath();
      if (emacsPath.isEmpty()) {
        Notifications.Bus.notify(
          new Notification(groupId, NOTIFICATION_TITLE,
            "Emacs executable path is empty"+
            "<br/><a href='configure'>Configure</a>",
          NotificationType.WARNING, new ErlangExternalToolsNotificationListener(project)), project);
        return;
      }
      commandLine.setExePath(emacsPath);
      commandLine.addParameters("--batch", "--eval");

      String sdkPath = getSdkPath(project);

      if (StringUtil.isEmpty(sdkPath)) {
        Notifications.Bus.notify(
          new Notification(groupId, NOTIFICATION_TITLE, "Erlang project SDK is not configured",
            NotificationType.WARNING), project);
        return;
      }

      final File tmpFile = FileUtil.createTempFile("emacs", ".erl", true);
      VirtualFile virtualTmpFile = LocalFileSystem.getInstance().findFileByIoFile(tmpFile);
      if (virtualTmpFile == null) {
        Notifications.Bus.notify(
          new Notification(groupId, NOTIFICATION_TITLE, "Failed to create a temporary file",
            NotificationType.WARNING), project);
        return;
      }

      boolean exists = new File(sdkPath, "lib/erlang/lib").exists();

      String emacsCommand = "\n" +
        "(progn (find-file \"" + virtualFile.getCanonicalPath() + "\")\n" +
        "    (setq erlang-root-dir \"" + sdkPath + "\")\n" +
        "    (setq load-path (cons (car (file-expand-wildcards (concat erlang-root-dir \"/lib/" + (exists ? "erlang/lib/" : "") + "tools-*/emacs\")))\n" +
        "                          load-path))\n" +
        "    (require 'erlang-start)\n" +
        "    (erlang-mode)\n" +
        "    (erlang-indent-current-buffer)\n" +
        "    (delete-trailing-whitespace)\n" +
        "    (untabify (point-min) (point-max))\n" +
        "    (write-region (point-min) (point-max) \"" + virtualTmpFile.getCanonicalPath() + "\")\n" +
        "    (kill-emacs))";

      commandLine.addParameter(emacsCommand);

      ApplicationManager.getApplication().saveAll();

      final String commandLineString = commandLine.getCommandLineString();
      OSProcessHandler handler = new OSProcessHandler(commandLine.createProcess(), commandLineString);
      handler.addProcessListener(new ProcessAdapter() {
        @Override
        public void processTerminated(ProcessEvent event) {
          ApplicationManager.getApplication().invokeLater(new Runnable() {
            @Override
View Full Code Here

TOP

Related Classes of com.intellij.execution.configurations.GeneralCommandLine

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.