private void executeTasks(@NotNull ExternalSystemTaskId id,
                            @NotNull List<String> tasks,
                            @NotNull String projectPath,
                            @NotNull GradleExecutionSettings settings,
                            @Nullable String jvmParametersSetup,
                            @NotNull ExternalSystemTaskNotificationListener listener,
                            @NotNull ProjectConnection connection,
                            @NotNull CancellationToken cancellationToken) {
    BuildEnvironment buildEnvironment = null;
    try {
      buildEnvironment = GradleExecutionHelper.getBuildEnvironment(connection, id, listener, cancellationToken, settings);
      var gradleVersion = getGradleVersion(buildEnvironment);

      setupGradleScriptDebugging(settings);
      setupDebuggerDispatchPort(settings);
      setupBuiltInTestEvents(settings, gradleVersion);

      appendInitScriptArgument(id.findProject(), tasks, jvmParametersSetup, settings, gradleVersion);

      for (GradleBuildParticipant buildParticipant : settings.getExecutionWorkspace().getBuildParticipants()) {
        settings.withArguments(GradleConstants.INCLUDE_BUILD_CMD_OPTION, buildParticipant.getProjectPath());
      }
      prepareTaskState(id, settings, listener);

      if (Registry.is("gradle.report.recently.saved.paths")) {
        ApplicationManager.getApplication()
          .getService(GradleFileModificationTracker.class)
          .notifyConnectionAboutChangedPaths(connection);
      }

      if (isApplicableTestLauncher(id, projectPath, tasks, settings, gradleVersion)) {
        TestLauncher launcher = myHelper.getTestLauncher(connection, id, tasks, settings, listener);
        launcher.withCancellationToken(cancellationToken);
        launcher.run();
      }
      else {
        BuildLauncher launcher = myHelper.getBuildLauncher(connection, id, tasks, settings, listener);
        launcher.withCancellationToken(cancellationToken);
        launcher.run();
      }
      GradleTaskResultListener.EP_NAME.forEachExtensionSafe(ext -> ext.onSuccess(id, projectPath));
    }
    catch (RuntimeException e) {
      LOG.debug("Gradle build launcher error", e);
      final GradleProjectResolverExtension projectResolverChain = GradleProjectResolver.createProjectResolverChain();
      throw projectResolverChain.getUserFriendlyError(buildEnvironment, e, projectPath, null);
    }
  }
private void executeTasks(@NotNull ExternalSystemTaskId id,
                            @NotNull List<String> tasks,
                            @NotNull String projectPath,
                            @NotNull GradleExecutionSettings settings,
                            @Nullable String jvmParametersSetup,
                            @NotNull ExternalSystemTaskNotificationListener listener,
                            @NotNull ProjectConnection connection,
                            @NotNull CancellationToken cancellationToken)