package jetbrains.mps.execution.configurations.implementation.plugin.plugin;

/*Generated by MPS */

import jetbrains.mps.execution.api.configurations.BaseMpsBeforeTaskProvider;
import com.intellij.openapi.util.Key;
import java.io.File;
import com.intellij.openapi.project.Project;
import com.intellij.execution.runners.ExecutionEnvironment;
import jetbrains.mps.util.FileUtil;

public class ClearSettingsDirectoryBeforeRunTask_BeforeTask extends BaseMpsBeforeTaskProvider<ClearSettingsDirectoryBeforeRunTask_BeforeTask.ClearSettingsDirectoryBeforeRunTask_BeforeTask_RunTask> {
  public static final Key<ClearSettingsDirectoryBeforeRunTask_BeforeTask_RunTask> KEY = Key.create("jetbrains.mps.execution.configurations.implementation.plugin.plugin.ClearSettingsDirectoryBeforeRunTask_BeforeTask");

  public ClearSettingsDirectoryBeforeRunTask_BeforeTask() {
    super("ClearSettingsDirectoryBeforeRunTask", "Clear Settings Directory");
  }

  protected ClearSettingsDirectoryBeforeRunTask_BeforeTask_RunTask createTaskImpl() {
    return new ClearSettingsDirectoryBeforeRunTask_BeforeTask_RunTask();
  }

  public Key<ClearSettingsDirectoryBeforeRunTask_BeforeTask_RunTask> getId() {
    return KEY;
  }

  public static class ClearSettingsDirectoryBeforeRunTask_BeforeTask_RunTask extends BaseMpsBeforeTaskProvider.BaseMpsBeforeRunTask<ClearSettingsDirectoryBeforeRunTask_BeforeTask_RunTask> {
    private boolean myDummy;
    private File mySettingsLocation;

    public ClearSettingsDirectoryBeforeRunTask_BeforeTask_RunTask() {
      super(KEY);
    }

    public boolean configure(boolean dummy, File settingsLocation) {
      myDummy = dummy;
      mySettingsLocation = settingsLocation;
      return true;
    }

    public boolean execute(Project project, ExecutionEnvironment environment) {
      // no way to separate here in-process/out-of-process execution
      if (myDummy) {
        return true;
      }
      FileUtil.delete(mySettingsLocation);
      return true;
    }
  }
}
