Java Code Examples for com.intellij.execution.process.OSProcessHandler#addProcessListener()

The following examples show how to use com.intellij.execution.process.OSProcessHandler#addProcessListener() . 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: OpenInXcodeAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static void openWithXcode(String path) {
  try {
    final GeneralCommandLine cmd = new GeneralCommandLine().withExePath("open").withParameters(path);
    final OSProcessHandler handler = new OSProcessHandler(cmd);
    handler.addProcessListener(new ProcessAdapter() {
      @Override
      public void processTerminated(@NotNull final ProcessEvent event) {
        if (event.getExitCode() != 0) {
          FlutterMessages.showError("Error Opening", path);
        }
      }
    });
    handler.startNotify();
  }
  catch (ExecutionException ex) {
    FlutterMessages.showError(
      "Error Opening",
      "Exception: " + ex.getMessage());
  }
}
 
Example 2
Source File: FlutterConsoleFilter.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void navigate(Project project) {
  try {
    final GeneralCommandLine cmd = new GeneralCommandLine().withExePath("open").withParameters(myPath);
    final OSProcessHandler handler = new OSProcessHandler(cmd);
    handler.addProcessListener(new ProcessAdapter() {
      @Override
      public void processTerminated(@NotNull final ProcessEvent event) {
        if (event.getExitCode() != 0) {
          FlutterMessages.showError("Error Opening ", myPath);
        }
      }
    });
    handler.startNotify();
  }
  catch (ExecutionException e) {
    FlutterMessages.showError(
      "Error Opening External File",
      "Exception: " + e.getMessage());
  }
}
 
Example 3
Source File: FlutterConsole.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Starts displaying the output of a different process.
 */
void watchProcess(@NotNull OSProcessHandler process) {
  if (cancelProcessSubscription != null) {
    cancelProcessSubscription.run();
    cancelProcessSubscription = null;
  }

  view.clear();
  view.attachToProcess(process);

  // Print exit code.
  final ProcessAdapter listener = new ProcessAdapter() {
    @Override
    public void processTerminated(final ProcessEvent event) {
      view.print(
        "Process finished with exit code " + event.getExitCode(),
        ConsoleViewContentType.SYSTEM_OUTPUT);
    }
  };
  process.addProcessListener(listener);
  cancelProcessSubscription = () -> process.removeProcessListener(listener);
}
 
Example 4
Source File: FlutterBuildActionGroup.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static OSProcessHandler build(Project project, @NotNull PubRoot pubRoot, FlutterSdk sdk, BuildType buildType, String desc) {
  ProgressHelper progressHelper = new ProgressHelper(project);
  progressHelper.start(desc);
  OSProcessHandler processHandler = sdk.flutterBuild(pubRoot, buildType.type).startInConsole(project);
  if (processHandler == null) {
    progressHelper.done();
  }
  else {
    processHandler.addProcessListener(new ProcessAdapter() {
      @Override
      public void processTerminated(@NotNull ProcessEvent event) {
        progressHelper.done();
        int exitCode = event.getExitCode();
        if (exitCode != 0) {
          FlutterMessages.showError("Error while building " + buildType, "`flutter build` returned: " + exitCode);
        }
      }
    });
  }
  return processHandler;
}
 
Example 5
Source File: OpenInXcodeAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static void openWithXcode(String path) {
  try {
    final GeneralCommandLine cmd = new GeneralCommandLine().withExePath("open").withParameters(path);
    final OSProcessHandler handler = new OSProcessHandler(cmd);
    handler.addProcessListener(new ProcessAdapter() {
      @Override
      public void processTerminated(@NotNull final ProcessEvent event) {
        if (event.getExitCode() != 0) {
          FlutterMessages.showError("Error Opening", path);
        }
      }
    });
    handler.startNotify();
  }
  catch (ExecutionException ex) {
    FlutterMessages.showError(
      "Error Opening",
      "Exception: " + ex.getMessage());
  }
}
 
Example 6
Source File: FlutterConsoleFilter.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void navigate(Project project) {
  try {
    final GeneralCommandLine cmd = new GeneralCommandLine().withExePath("open").withParameters(myPath);
    final OSProcessHandler handler = new OSProcessHandler(cmd);
    handler.addProcessListener(new ProcessAdapter() {
      @Override
      public void processTerminated(@NotNull final ProcessEvent event) {
        if (event.getExitCode() != 0) {
          FlutterMessages.showError("Error Opening ", myPath);
        }
      }
    });
    handler.startNotify();
  }
  catch (ExecutionException e) {
    FlutterMessages.showError(
      "Error Opening External File",
      "Exception: " + e.getMessage());
  }
}
 
Example 7
Source File: FlutterConsole.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Starts displaying the output of a different process.
 */
void watchProcess(@NotNull OSProcessHandler process) {
  if (cancelProcessSubscription != null) {
    cancelProcessSubscription.run();
    cancelProcessSubscription = null;
  }

  view.clear();
  view.attachToProcess(process);

  // Print exit code.
  final ProcessAdapter listener = new ProcessAdapter() {
    @Override
    public void processTerminated(final ProcessEvent event) {
      view.print(
        "Process finished with exit code " + event.getExitCode(),
        ConsoleViewContentType.SYSTEM_OUTPUT);
    }
  };
  process.addProcessListener(listener);
  cancelProcessSubscription = () -> process.removeProcessListener(listener);
}
 
Example 8
Source File: FlutterBuildActionGroup.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static OSProcessHandler build(Project project, @NotNull PubRoot pubRoot, FlutterSdk sdk, BuildType buildType, String desc) {
  ProgressHelper progressHelper = new ProgressHelper(project);
  progressHelper.start(desc);
  OSProcessHandler processHandler = sdk.flutterBuild(pubRoot, buildType.type).startInConsole(project);
  if (processHandler == null) {
    progressHelper.done();
  }
  else {
    processHandler.addProcessListener(new ProcessAdapter() {
      @Override
      public void processTerminated(@NotNull ProcessEvent event) {
        progressHelper.done();
        int exitCode = event.getExitCode();
        if (exitCode != 0) {
          FlutterMessages.showError("Error while building " + buildType, "`flutter build` returned: " + exitCode);
        }
      }
    });
  }
  return processHandler;
}
 
Example 9
Source File: OpenInAndroidStudioAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void openFileInStudio(@NotNull VirtualFile projectFile, @NotNull String androidStudioPath, @Nullable String sourceFile) {
  try {
    final GeneralCommandLine cmd;
    if (SystemInfo.isMac) {
      cmd = new GeneralCommandLine().withExePath("open").withParameters("-a", androidStudioPath, "--args", projectFile.getPath());
      if (sourceFile != null) {
        cmd.addParameter(sourceFile);
      }
    }
    else {
      // TODO Open editor on sourceFile for Linux, Windows
      if (SystemInfo.isWindows) {
        androidStudioPath += "\\bin\\studio.bat";
      }
      cmd = new GeneralCommandLine().withExePath(androidStudioPath).withParameters(projectFile.getPath());
    }
    final OSProcessHandler handler = new OSProcessHandler(cmd);
    handler.addProcessListener(new ProcessAdapter() {
      @Override
      public void processTerminated(@NotNull final ProcessEvent event) {
        if (event.getExitCode() != 0) {
          FlutterMessages.showError("Error Opening", projectFile.getPath());
        }
      }
    });
    handler.startNotify();
  }
  catch (ExecutionException ex) {
    FlutterMessages.showError(
      "Error Opening",
      "Exception: " + ex.getMessage());
  }
}
 
Example 10
Source File: OpenInAndroidStudioAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void openFileInStudio(@NotNull VirtualFile projectFile, @NotNull String androidStudioPath, @Nullable String sourceFile) {
  try {
    final GeneralCommandLine cmd;
    if (SystemInfo.isMac) {
      cmd = new GeneralCommandLine().withExePath("open").withParameters("-a", androidStudioPath, "--args", projectFile.getPath());
      if (sourceFile != null) {
        cmd.addParameter(sourceFile);
      }
    }
    else {
      // TODO Open editor on sourceFile for Linux, Windows
      if (SystemInfo.isWindows) {
        androidStudioPath += "\\bin\\studio.bat";
      }
      cmd = new GeneralCommandLine().withExePath(androidStudioPath).withParameters(projectFile.getPath());
    }
    final OSProcessHandler handler = new OSProcessHandler(cmd);
    handler.addProcessListener(new ProcessAdapter() {
      @Override
      public void processTerminated(@NotNull final ProcessEvent event) {
        if (event.getExitCode() != 0) {
          FlutterMessages.showError("Error Opening", projectFile.getPath());
        }
      }
    });
    handler.startNotify();
  }
  catch (ExecutionException ex) {
    FlutterMessages.showError(
      "Error Opening",
      "Exception: " + ex.getMessage());
  }
}
 
Example 11
Source File: PantsIntegrationTestCase.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
@NotNull
protected RunResult runWithConfiguration(RunConfiguration configuration) {
  PantsMakeBeforeRun.replaceDefaultMakeWithPantsMake(configuration);
  PantsMakeBeforeRun.setRunConfigurationWorkingDirectory(configuration);
  PantsJUnitRunnerAndConfigurationSettings runnerAndConfigurationSettings =
    new PantsJUnitRunnerAndConfigurationSettings(configuration);
  ExecutionEnvironmentBuilder environmentBuilder =
    ExecutionUtil.createEnvironment(DefaultRunExecutor.getRunExecutorInstance(), runnerAndConfigurationSettings);
  ExecutionEnvironment environment = environmentBuilder.build();

  List<String> output = new ArrayList<>();
  List<String> errors = new ArrayList<>();
  ProcessAdapter processAdapter = new ProcessAdapter() {
    @Override
    public void onTextAvailable(@NotNull ProcessEvent event, @NotNull Key outputType) {
      if (outputType == ProcessOutputTypes.STDOUT) {
        output.add(event.getText());
      }
      else if (outputType == ProcessOutputTypes.STDERR) {
        errors.add(event.getText());
      }
    }
  };

  ProgramRunnerUtil.executeConfiguration(environment, false, false);
  OSProcessHandler handler = (OSProcessHandler) environment.getContentToReuse().getProcessHandler();
  handler.addProcessListener(processAdapter);
  assertTrue(handler.waitFor());

  return new RunResult(handler.getExitCode(), output, errors);
}
 
Example 12
Source File: AndroidSdk.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@NotNull
public List<AndroidEmulator> getEmulators() {
  // Execute $ANDROID_HOME/emulator/emulator -list-avds and parse the results.
  final VirtualFile emulator = getEmulatorToolExecutable();
  if (emulator == null) {
    return Collections.emptyList();
  }

  final String emulatorPath = emulator.getCanonicalPath();
  assert (emulatorPath != null);

  final GeneralCommandLine cmd = new GeneralCommandLine()
    .withParentEnvironmentType(GeneralCommandLine.ParentEnvironmentType.CONSOLE)
    .withWorkDirectory(home.getCanonicalPath())
    .withExePath(emulatorPath)
    .withParameters("-list-avds");

  try {
    final StringBuilder stringBuilder = new StringBuilder();
    final OSProcessHandler process = new OSProcessHandler(cmd);
    process.addProcessListener(new ProcessAdapter() {
      @Override
      public void onTextAvailable(ProcessEvent event, Key outputType) {
        if (outputType == ProcessOutputTypes.STDOUT) {
          stringBuilder.append(event.getText());
        }
      }
    });
    process.startNotify();

    // We wait a maximum of 10s.
    if (!process.waitFor(10000)) {
      return Collections.emptyList();
    }

    final Integer exitCode = process.getExitCode();
    if (exitCode == null || process.getExitCode() != 0) {
      return Collections.emptyList();
    }

    // 'emulator -list-avds' results are in the form "foo\nbar\nbaz\n".
    final List<AndroidEmulator> emulators = new ArrayList<>();

    for (String str : stringBuilder.toString().split("\n")) {
      str = str.trim();
      if (str.isEmpty()) {
        continue;
      }
      emulators.add(new AndroidEmulator(this, str));
    }

    return emulators;
  }
  catch (ExecutionException | RuntimeException e) {
    FlutterUtils.warn(LOG, "Error listing android emulators", e);
    return Collections.emptyList();
  }
}
 
Example 13
Source File: OpenInXcodeAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static void openFile(@NotNull VirtualFile file) {
  final Project project = ProjectUtil.guessProjectForFile(file);
  final FlutterSdk sdk = project != null ? FlutterSdk.getFlutterSdk(project) : null;
  if (sdk == null) {
    FlutterSdkAction.showMissingSdkDialog(project);
    return;
  }

  final PubRoot pubRoot = PubRoot.forFile(file);
  if (pubRoot == null) {
    FlutterMessages.showError("Error Opening Xcode", "Unable to run `flutter build` (no pub root found)");
    return;
  }

  // Trigger an iOS build if necessary.
  if (!hasBeenBuilt(pubRoot)) {
    final ProgressHelper progressHelper = new ProgressHelper(project);
    progressHelper.start("Building for iOS");

    // TODO(pq): consider a popup explaining why we're doing a build.
    // Note: we build only for the simulator to bypass device provisioning issues.
    final OSProcessHandler processHandler = sdk.flutterBuild(pubRoot, "ios", "--simulator").startInConsole(project);
    if (processHandler == null) {
      progressHelper.done();
      FlutterMessages.showError("Error Opening Xcode", "unable to run `flutter build`");
    }
    else {
      processHandler.addProcessListener(new ProcessAdapter() {
        @Override
        public void processTerminated(@NotNull ProcessEvent event) {
          progressHelper.done();

          final int exitCode = event.getExitCode();
          if (exitCode != 0) {
            FlutterMessages.showError("Error Opening Xcode", "`flutter build` returned: " + exitCode);
            return;
          }

          openWithXcode(file.getPath());
        }
      });
    }
  }
  else {
    openWithXcode(file.getPath());
  }
}
 
Example 14
Source File: OpenInXcodeAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static void openFile(@NotNull VirtualFile file) {
  final Project project = ProjectUtil.guessProjectForFile(file);
  final FlutterSdk sdk = project != null ? FlutterSdk.getFlutterSdk(project) : null;
  if (sdk == null) {
    FlutterSdkAction.showMissingSdkDialog(project);
    return;
  }

  final PubRoot pubRoot = PubRoot.forFile(file);
  if (pubRoot == null) {
    FlutterMessages.showError("Error Opening Xcode", "Unable to run `flutter build` (no pub root found)");
    return;
  }

  // Trigger an iOS build if necessary.
  if (!hasBeenBuilt(pubRoot)) {
    final ProgressHelper progressHelper = new ProgressHelper(project);
    progressHelper.start("Building for iOS");

    // TODO(pq): consider a popup explaining why we're doing a build.
    // Note: we build only for the simulator to bypass device provisioning issues.
    final OSProcessHandler processHandler = sdk.flutterBuild(pubRoot, "ios", "--simulator").startInConsole(project);
    if (processHandler == null) {
      progressHelper.done();
      FlutterMessages.showError("Error Opening Xcode", "unable to run `flutter build`");
    }
    else {
      processHandler.addProcessListener(new ProcessAdapter() {
        @Override
        public void processTerminated(@NotNull ProcessEvent event) {
          progressHelper.done();

          final int exitCode = event.getExitCode();
          if (exitCode != 0) {
            FlutterMessages.showError("Error Opening Xcode", "`flutter build` returned: " + exitCode);
            return;
          }

          openWithXcode(file.getPath());
        }
      });
    }
  }
  else {
    openWithXcode(file.getPath());
  }
}
 
Example 15
Source File: AndroidSdk.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@NotNull
public List<AndroidEmulator> getEmulators() {
  // Execute $ANDROID_HOME/emulator/emulator -list-avds and parse the results.
  final VirtualFile emulator = getEmulatorToolExecutable();
  if (emulator == null) {
    return Collections.emptyList();
  }

  final String emulatorPath = emulator.getCanonicalPath();
  assert (emulatorPath != null);

  final GeneralCommandLine cmd = new GeneralCommandLine()
    .withParentEnvironmentType(GeneralCommandLine.ParentEnvironmentType.CONSOLE)
    .withWorkDirectory(home.getCanonicalPath())
    .withExePath(emulatorPath)
    .withParameters("-list-avds");

  try {
    final StringBuilder stringBuilder = new StringBuilder();
    final OSProcessHandler process = new OSProcessHandler(cmd);
    process.addProcessListener(new ProcessAdapter() {
      @Override
      public void onTextAvailable(ProcessEvent event, Key outputType) {
        if (outputType == ProcessOutputTypes.STDOUT) {
          stringBuilder.append(event.getText());
        }
      }
    });
    process.startNotify();

    // We wait a maximum of 10s.
    if (!process.waitFor(10000)) {
      return Collections.emptyList();
    }

    final Integer exitCode = process.getExitCode();
    if (exitCode == null || process.getExitCode() != 0) {
      return Collections.emptyList();
    }

    // 'emulator -list-avds' results are in the form "foo\nbar\nbaz\n".
    final List<AndroidEmulator> emulators = new ArrayList<>();

    for (String str : stringBuilder.toString().split("\n")) {
      str = str.trim();
      if (str.isEmpty()) {
        continue;
      }
      emulators.add(new AndroidEmulator(this, str));
    }

    return emulators;
  }
  catch (ExecutionException | RuntimeException e) {
    FlutterUtils.warn(LOG, "Error listing android emulators", e);
    return Collections.emptyList();
  }
}
 
Example 16
Source File: BlazeIntellijPluginConfiguration.java    From intellij with Apache License 2.0 4 votes vote down vote up
/**
 * Plugin jar has been previously created via blaze build. This method: - copies jar to sandbox
 * environment - cracks open jar and finds plugin.xml (with ID, etc., needed for JVM args) - sets
 * up the SDK, etc. (use project SDK?) - sets up the JVM, and returns a JavaCommandLineState
 */
@Nullable
@Override
public RunProfileState getState(Executor executor, ExecutionEnvironment env)
    throws ExecutionException {
  final Sdk ideaJdk = pluginSdk;
  if (!IdeaJdkHelper.isIdeaJdk(ideaJdk)) {
    throw new ExecutionException("Choose an IntelliJ Platform Plugin SDK");
  }
  String sandboxHome = IdeaJdkHelper.getSandboxHome(ideaJdk);
  if (sandboxHome == null) {
    throw new ExecutionException("No sandbox specified for IntelliJ Platform Plugin SDK");
  }

  try {
    sandboxHome = new File(sandboxHome).getCanonicalPath();
  } catch (IOException e) {
    throw new ExecutionException("No sandbox specified for IntelliJ Platform Plugin SDK", e);
  }
  String buildNumber = IdeaJdkHelper.getBuildNumber(ideaJdk);
  final BlazeIntellijPluginDeployer deployer =
      new BlazeIntellijPluginDeployer(sandboxHome, buildNumber, target);
  env.putUserData(BlazeIntellijPluginDeployer.USER_DATA_KEY, deployer);

  // copy license from running instance of idea
  IdeaJdkHelper.copyIDEALicense(sandboxHome);

  return new JavaCommandLineState(env) {
    @Override
    protected JavaParameters createJavaParameters() throws ExecutionException {
      DeployedPluginInfo deployedPluginInfo = deployer.deployNonBlocking();

      final JavaParameters params = new JavaParameters();

      ParametersList vm = params.getVMParametersList();

      fillParameterList(vm, vmParameters);
      fillParameterList(params.getProgramParametersList(), programParameters);

      IntellijWithPluginClasspathHelper.addRequiredVmParams(
          params, ideaJdk, deployedPluginInfo.javaAgents);

      vm.defineProperty(
          JetBrainsProtocolHandler.REQUIRED_PLUGINS_KEY,
          Joiner.on(',').join(deployedPluginInfo.pluginIds));

      if (!vm.hasProperty(PlatformUtils.PLATFORM_PREFIX_KEY) && buildNumber != null) {
        String prefix = IdeaJdkHelper.getPlatformPrefix(buildNumber);
        if (prefix != null) {
          vm.defineProperty(PlatformUtils.PLATFORM_PREFIX_KEY, prefix);
        }
      }
      return params;
    }

    /** https://youtrack.jetbrains.com/issue/IDEA-201733 */
    @Override
    protected GeneralCommandLine createCommandLine() throws ExecutionException {
      GeneralCommandLine commandLine = super.createCommandLine();
      for (String jreName : new String[] {"jbr", "jre64", "jre"}) {
        File bundledJre = new File(ideaJdk.getHomePath(), jreName);
        if (bundledJre.isDirectory()) {
          File bundledJava = new File(bundledJre, "bin/java");
          if (bundledJava.canExecute()) {
            commandLine.setExePath(bundledJava.getAbsolutePath());
            break;
          }
        }
      }
      return commandLine;
    }

    @Override
    protected OSProcessHandler startProcess() throws ExecutionException {
      deployer.blockUntilDeployComplete();
      final OSProcessHandler handler = super.startProcess();
      handler.addProcessListener(
          new ProcessAdapter() {
            @Override
            public void processTerminated(ProcessEvent event) {
              deployer.deleteDeployment();
            }
          });
      return handler;
    }
  };
}
 
Example 17
Source File: FastBuildRunProfileState.java    From intellij with Apache License 2.0 4 votes vote down vote up
@Override
protected ProcessHandler startProcess() throws ExecutionException {
  File outputFile = createOutputFile();
  Project project = getConfiguration().getProject();
  Label label = getLabel();
  BlazeTestUiSession testUiSession =
      BlazeTestUiSession.create(
          /* blazeFlags= */ ImmutableList.of(),
          new FastBuildTestResultFinderStrategy(
              label, getConfiguration().getTargetKind(), outputFile, getBlazeContext()));
  setConsoleBuilder(
      new TextConsoleBuilderImpl(project) {
        @Override
        protected ConsoleView createConsole() {
          return SmRunnerUtils.getConsoleView(
              project, getConfiguration(), getEnvironment().getExecutor(), testUiSession);
        }
      });

  BlazeJavaRunConfigState handlerState =
      (BlazeJavaRunConfigState) getConfiguration().getHandler().getState();

  int debugPort = -1;
  if (getExecutorType().isDebugType()) {
    debugPort = handlerState.getDebugPortState().port;
  }

  FastBuildTestEnvironmentCreator testEnvironmentCreator =
      FastBuildTestEnvironmentCreator.getInstance(Blaze.getBuildSystem(project));

  GeneralCommandLine commandLine =
      testEnvironmentCreator.createCommandLine(
          project,
          getConfiguration(),
          getFastBuildInfo(),
          outputFile,
          handlerState.getTestFilterForExternalProcesses(),
          debugPort);

  Stopwatch timer = Stopwatch.createStarted();
  OSProcessHandler processHandler = JavaCommandLineStateUtil.startProcess(commandLine);
  processHandler.addProcessListener(new LoggingProcessListener(commandLine, timer));
  return processHandler;
}
 
Example 18
Source File: PluginGeneratorUtil.java    From idea-php-shopware-plugin with MIT License 4 votes vote down vote up
public static void installPlugin(@NotNull Project project, @NotNull PluginGeneratorSettings settings) {

        // download cli tools, if not existing locally
        VirtualFile cliFile = getCliToolsPharFile(project);
        if (cliFile == null) {
            showErrorNotification(project, "No CLI-Tools phar found");
            return;
        }

        List<String> commands = generateCommand(settings);

        String[] myCommand = ArrayUtil.toStringArray(commands);

        final StringBuilder outputBuilder = new StringBuilder();
        try {
            OSProcessHandler processHandler = ScriptRunnerUtil.execute(myCommand[0], project.getBaseDir().getPath(), null, Arrays.copyOfRange(myCommand, 1, myCommand.length));

            processHandler.addProcessListener(new ProcessAdapter() {
                @Override
                public void onTextAvailable(@NotNull ProcessEvent event, @NotNull com.intellij.openapi.util.Key outputType) {
                    String text = event.getText();
                    outputBuilder.append(text);
                }
            });

            processHandler.startNotify();
            for (;;){
                boolean finished = processHandler.waitFor(CHECKING_TIMEOUT_IN_MILLISECONDS);
                if (finished) {
                    break;
                }
            }
        }
        catch (ExecutionException e) {
            showErrorNotification(project, e.getMessage());
            return;
        }

        String output = outputBuilder.toString();
        if (output.toLowerCase().contains("exception")) {

            String message = SymfonyInstallerUtil.formatExceptionMessage(output);
            if(message == null) {
                message = "The unexpected happens...";
            }

            showErrorNotification(project, message);
            return;
        }

        // delete cli tools
        FileUtil.delete(VfsUtil.virtualToIoFile(cliFile));

        // move into correct plugin folder
        String newDir = project.getBasePath() + "/engine/Shopware/Plugins/Local/" + settings.getNamespace() + "/" + settings.getPluginName();
        if (FileUtil.canWrite(newDir)) {
            return;
        }

        FileUtil.createDirectory(new File(newDir));
        FileUtil.moveDirWithContent(new File(project.getBasePath() + "/" + settings.getPluginName()), new File(newDir));

        // open bootstrap file
        VirtualFile fileByIoFile = VfsUtil.findFileByIoFile(new File(newDir + "/Bootstrap.php"), true);
        if(fileByIoFile == null) {
            return;
        }
        final PsiFile file = PsiManager.getInstance(project).findFile(fileByIoFile);
        if (file == null) {
            return;
        }
        IdeHelper.navigateToPsiElement(file);
    }