com.intellij.execution.CommonProgramRunConfigurationParameters Java Examples

The following examples show how to use com.intellij.execution.CommonProgramRunConfigurationParameters. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PantsMakeBeforeRun.java    From intellij-pants-plugin with Apache License 2.0 6 votes vote down vote up
public static void setRunConfigurationWorkingDirectory(@NotNull RunConfiguration runConfiguration) {
  Optional<VirtualFile> buildRoot = PantsUtil.findBuildRoot(runConfiguration.getProject());

  /**
   /**
   * Scala related run/test configuration inherit {@link AbstractTestRunConfiguration}
   * Use string test on class name due to scala plugin can be optional and it is hard to separate this logic.
   */
  if (PantsUtil.isScalaRelatedTestRunConfiguration(runConfiguration)) {
    buildRoot
      .map(VirtualFile::getPath)
      .ifPresent(((AbstractTestRunConfiguration) runConfiguration).testConfigurationData()::setWorkingDirectory);
  }
  /**
   * JUnit, Application, etc configuration inherit {@link CommonProgramRunConfigurationParameters}
   */
  else if (runConfiguration instanceof CommonProgramRunConfigurationParameters) {
    buildRoot
      .map(VirtualFile::getPath)
      .ifPresent(((CommonProgramRunConfigurationParameters) runConfiguration)::setWorkingDirectory);
  }
}
 
Example #2
Source File: ProgramParametersConfigurator.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void configureConfiguration(SimpleProgramParameters parameters, CommonProgramRunConfigurationParameters configuration) {
  Project project = configuration.getProject();
  Module module = getModule(configuration);

  parameters.getProgramParametersList().addParametersString(expandPath(configuration.getProgramParameters(), module, project));

  parameters.setWorkingDirectory(getWorkingDir(configuration, project, module));

  Map<String, String> envs = new HashMap<>(configuration.getEnvs());
  EnvironmentUtil.inlineParentOccurrences(envs);
  for (Map.Entry<String, String> each : envs.entrySet()) {
    each.setValue(expandPath(each.getValue(), module, project));
  }

  parameters.setEnv(envs);
  parameters.setPassParentEnvs(configuration.isPassParentEnvs());
}
 
Example #3
Source File: ProgramParametersConfigurator.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
public String getWorkingDir(CommonProgramRunConfigurationParameters configuration, Project project, Module module) {
  String workingDirectory = configuration.getWorkingDirectory();
  String defaultWorkingDir = getDefaultWorkingDir(project);
  if (StringUtil.isEmptyOrSpaces(workingDirectory)) {
    workingDirectory = defaultWorkingDir;
    if (workingDirectory == null) {
      return null;
    }
  }
  workingDirectory = expandPath(workingDirectory, module, project);
  if (!FileUtil.isAbsolute(workingDirectory) && defaultWorkingDir != null) {
    if (("$" + PathMacroUtil.MODULE_DIR_MACRO_NAME + "$").equals(workingDirectory)) {
      return defaultWorkingDir;
    }

    if (module != null && MODULE_WORKING_DIR.equals(workingDirectory)) {
      String workingDir = getDefaultWorkingDir(module);
      if (workingDir != null) return workingDir;
    }
    workingDirectory = defaultWorkingDir + "/" + workingDirectory;
  }
  return workingDirectory;
}
 
Example #4
Source File: ProgramParametersConfigurator.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void checkWorkingDirectoryExist(CommonProgramRunConfigurationParameters configuration, Project project, Module module) throws RuntimeConfigurationWarning {
  final String workingDir = getWorkingDir(configuration, project, module);
  if (workingDir == null) {
    throw new RuntimeConfigurationWarning("Working directory is null for " +
                                          "project '" +
                                          project.getName() +
                                          "' (" +
                                          project.getBasePath() +
                                          ")" +
                                          ", module " +
                                          (module == null ? "null" : "'" + module.getName() + "' (" + module.getModuleDirPath() + ")"));
  }
  if (!new File(workingDir).exists()) {
    throw new RuntimeConfigurationWarning("Working directory '" + workingDir + "' doesn't exist");
  }
}
 
Example #5
Source File: PantsMakeBeforeRun.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
public static void replaceDefaultMakeWithPantsMake(@NotNull RunConfiguration runConfiguration) {
  if (!PantsUtil.isScalaRelatedTestRunConfiguration(runConfiguration) &&
      !(runConfiguration instanceof CommonProgramRunConfigurationParameters)) {
    return;
  }

  RunManager runManager = RunManager.getInstance(runConfiguration.getProject());
  RunManagerImpl runManagerImpl = (RunManagerImpl) runManager;
  BeforeRunTask pantsMakeTask = new ExternalSystemBeforeRunTask(ID, PantsConstants.SYSTEM_ID);
  pantsMakeTask.setEnabled(true);
  runManagerImpl.setBeforeRunTasks(runConfiguration, Collections.singletonList(pantsMakeTask));
}
 
Example #6
Source File: CommonProgramParametersPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void applyTo(CommonProgramRunConfigurationParameters configuration) {
  configuration.setProgramParameters(fromTextField(myProgramParametersComponent.getComponent(), configuration));
  configuration.setWorkingDirectory(fromTextField(myWorkingDirectoryComboBox, configuration));

  configuration.setEnvs(myEnvVariablesComponent.getEnvs());
  configuration.setPassParentEnvs(myEnvVariablesComponent.isPassParentEnvs());
}
 
Example #7
Source File: CommonProgramParametersPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void reset(CommonProgramRunConfigurationParameters configuration) {
  setProgramParameters(configuration.getProgramParameters());
  setWorkingDirectory(PathUtil.toSystemDependentName(configuration.getWorkingDirectory()));

  myEnvVariablesComponent.setEnvs(configuration.getEnvs());
  myEnvVariablesComponent.setPassParentEnvs(configuration.isPassParentEnvs());
}
 
Example #8
Source File: ProgramParametersConfigurator.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
protected Module getModule(CommonProgramRunConfigurationParameters configuration) {
  if (configuration instanceof ModuleBasedConfiguration) {
    return ((ModuleBasedConfiguration)configuration).getConfigurationModule().getModule();
  }
  return null;
}
 
Example #9
Source File: GaugeRunConfiguration.java    From Intellij-Plugin with Apache License 2.0 4 votes vote down vote up
public CommonProgramRunConfigurationParameters getProgramParameters() {
    return programParameters;
}
 
Example #10
Source File: XQueryRunProfileState.java    From intellij-xquery with Apache License 2.0 4 votes vote down vote up
private Module getModule(CommonProgramRunConfigurationParameters configuration) {
    return configuration instanceof ModuleBasedConfiguration ? ((ModuleBasedConfiguration) configuration).getConfigurationModule().getModule() : null;
}
 
Example #11
Source File: CommonProgramParametersPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
protected String fromTextField(@Nonnull TextAccessor textAccessor, @Nonnull CommonProgramRunConfigurationParameters configuration) {
  return textAccessor.getText();
}
 
Example #12
Source File: ProgramParametersUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static void configureConfiguration(SimpleProgramParameters parameters, CommonProgramRunConfigurationParameters configuration) {
  new ProgramParametersConfigurator().configureConfiguration(parameters, configuration);
}
 
Example #13
Source File: ProgramParametersUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static String getWorkingDir(CommonProgramRunConfigurationParameters configuration, Project project, Module module) {
  return new ProgramParametersConfigurator().getWorkingDir(configuration, project, module);
}
 
Example #14
Source File: ProgramParametersUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static void checkWorkingDirectoryExist(CommonProgramRunConfigurationParameters configuration, Project project, Module module)
  throws RuntimeConfigurationWarning {
  new ProgramParametersConfigurator().checkWorkingDirectoryExist(configuration, project, module);
}
 
Example #15
Source File: ProgramParametersUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
public static Module getModule(CommonProgramRunConfigurationParameters configuration) {
  return new ProgramParametersConfigurator().getModule(configuration);
}