public static boolean doExecuteTask(final @NotNull ExecutionEnvironment env,
                                      final @NotNull RunnerAndConfigurationSettings settings,
                                      final @Nullable ExecutionTarget target) {
    RunConfiguration configuration = settings.getConfiguration();
    Executor executor = configuration instanceof BeforeRunTaskAwareConfiguration &&
                        ((BeforeRunTaskAwareConfiguration)configuration).useRunExecutor()
                        ? DefaultRunExecutor.getRunExecutorInstance()
                        : env.getExecutor();
    final String executorId = executor.getId();
    ExecutionEnvironmentBuilder builder = ExecutionEnvironmentBuilder.createOrNull(executor, settings);
    if (builder == null) {
      LOG.info("Cannot create environment builder for 'Before launch' task '" + settings.getName() + "' in '" + env.getRunProfile().getName() + "', task is skipped");
      return false;
    }

    ExecutionTarget effectiveTarget = target;

    if (effectiveTarget == null && ExecutionTargetManager.canRun(settings.getConfiguration(), env.getExecutionTarget())) {
      effectiveTarget = env.getExecutionTarget();
    }

    List<ExecutionTarget> allTargets = ExecutionTargetManager.getInstance(env.getProject()).getTargetsFor(settings.getConfiguration());
    if (effectiveTarget == null) {
      effectiveTarget = ContainerUtil.find(allTargets, it -> it.isReady());
    }
    if (effectiveTarget == null) {
      effectiveTarget = ContainerUtil.getFirstItem(allTargets);
    }

    if (effectiveTarget == null) {
      LOG.debug("No suitable targets for 'Before launch' task '" + settings.getName() + "' in '" + env.getRunProfile().getName() + "', task is skipped");
      return false;
    }

    final ExecutionEnvironment environment = builder.target(effectiveTarget).build();
    environment.setExecutionId(env.getExecutionId());
    env.copyUserDataTo(environment);

    if (!environment.getRunner().canRun(executorId, environment.getRunProfile())) {
      LOG.debug("'canRun' returned 'false' for 'Before launch' task '" + settings.getName() + "' in '" + env.getRunProfile().getName() + "', task is skipped");
      return false;
    }
    else {
      beforeRun(environment);
      LOG.debug("Starting 'Before launch' task '" + settings.getName() + "' in '" + env.getRunProfile().getName() + "'");
      return doRunTask(executorId, environment, environment.getRunner());
    }
  }
public static boolean doExecuteTask(final @NotNull ExecutionEnvironment env,
                                      final @NotNull RunnerAndConfigurationSettings settings,
                                      final @Nullable ExecutionTarget target)