private boolean doRunMavenTask(Project project, MavenBeforeRunTask task, ExecutionEnvironment env) {
    final MavenProject mavenProject = getMavenProject(task);
    if (mavenProject == null) return false;
    final MavenExplicitProfiles explicitProfiles = MavenProjectsManager.getInstance(project).getExplicitProfiles();

    MavenRunnerParameters params = new MavenRunnerParameters(
      true,
      mavenProject.getDirectory(),
      mavenProject.getFile().getName(),
      ParametersListUtil.parse(task.getGoal()),
      explicitProfiles.getEnabledProfiles(),
      explicitProfiles.getDisabledProfiles());

    RunnerAndConfigurationSettings configuration =
      MavenRunConfigurationType.createRunnerAndConfigurationSettings(null, null, params, myProject);
    ProgramRunner runner = DefaultJavaProgramRunner.getInstance();
    Executor executor = DefaultRunExecutor.getRunExecutorInstance();
    ExecutionEnvironment environment = new ExecutionEnvironment(executor, runner, configuration, project);
    environment.setExecutionId(env.getExecutionId());

    if (!environment.getRunner().canRun(executor.getId(), environment.getRunProfile())) {
      MavenLog.LOG.warn("Can't run " + task.getGoal() + " on runner=" + runner.getRunnerId() + ", executorId=" + executor.getId());
      return false;
    }

    return RunConfigurationBeforeRunProvider.doRunTask(executor.getId(), environment, runner);
  }
private boolean doRunMavenTask(Project project, MavenBeforeRunTask task, ExecutionEnvironment env)