boolean (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) { 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) { return false; } final ExecutionEnvironment environment = builder.target(effectiveTarget).build(); environment.setExecutionId(env.getExecutionId()); env.copyUserDataTo(environment); if (!environment.getRunner().canRun(executorId, environment.getRunProfile())) { return false; } else { beforeRun(environment); return doRunTask(executorId, environment, environment.getRunner()); } }