com.intellij.execution.configurations.RunConfiguration Java Examples

The following examples show how to use com.intellij.execution.configurations.RunConfiguration. 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: TaskConfigurationTargetProvider.java    From JHelper with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public @NotNull List<ExecutionTarget> getTargets(
		@NotNull Project project,
		@NotNull RunConfiguration configuration
) {
	if (!(configuration instanceof TaskConfiguration)) {
		return Collections.emptyList();
	}
	RunnerAndConfigurationSettings testRunner = TaskRunner.getRunnerSettings(project);
	if (testRunner == null) {
		return Collections.emptyList();
	}
	List<ExecutionTarget> runnerTargets = ExecutionTargetManager.getInstance(project).getTargetsFor(testRunner.getConfiguration());
	List<ExecutionTarget> myTargets = new ArrayList<>();
	for (ExecutionTarget target : runnerTargets) {
		myTargets.add(new TaskConfigurationExecutionTarget(target));
	}
	return myTargets;
}
 
Example #2
Source File: AbstractRunConfigurationTypeUsagesCollector.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public final Set<UsageDescriptor> getProjectUsages(@Nonnull final Project project) {
  final Set<String> runConfigurationTypes = new HashSet<String>();
  UIUtil.invokeAndWaitIfNeeded(new Runnable() {
    @Override
    public void run() {
      if (project.isDisposed()) return;
      final RunManager runManager = RunManager.getInstance(project);
      for (RunConfiguration runConfiguration : runManager.getAllConfigurationsList()) {
        if (runConfiguration != null && isApplicable(runManager, runConfiguration)) {
          final ConfigurationFactory configurationFactory = runConfiguration.getFactory();
          final ConfigurationType configurationType = configurationFactory.getType();
          final StringBuilder keyBuilder = new StringBuilder();
          keyBuilder.append(configurationType.getId());
          if (configurationType.getConfigurationFactories().length > 1) {
            keyBuilder.append(".").append(configurationFactory.getName());
          }
          runConfigurationTypes.add(keyBuilder.toString());
        }
      }
    }
  });
  return ContainerUtil.map2Set(runConfigurationTypes, runConfigurationType -> new UsageDescriptor(runConfigurationType, 1));
}
 
Example #3
Source File: BlazeJavaAbstractTestCaseConfigurationProducer.java    From intellij with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
static void chooseSubclass(
    ConfigurationFromContext configuration,
    ConfigurationContext context,
    Runnable startRunnable) {
  RunConfiguration config = configuration.getConfiguration();
  if (!(config instanceof BlazeCommandRunConfiguration)) {
    return;
  }
  AbstractTestLocation location = locationFromConfiguration(configuration);
  if (location == null) {
    return;
  }
  SubclassTestChooser.chooseSubclass(
      context,
      location.abstractClass,
      (psiClass) -> {
        if (psiClass != null) {
          setupContext((BlazeCommandRunConfiguration) config, psiClass, location.method);
        }
        startRunnable.run();
      });
}
 
Example #4
Source File: BlazeAndroidBinaryNormalBuildRunContextBase.java    From intellij with Apache License 2.0 6 votes vote down vote up
BlazeAndroidBinaryNormalBuildRunContextBase(
    Project project,
    AndroidFacet facet,
    RunConfiguration runConfiguration,
    ExecutionEnvironment env,
    BlazeAndroidBinaryRunConfigurationState configState,
    Label label,
    ImmutableList<String> blazeFlags) {
  this.project = project;
  this.facet = facet;
  this.runConfiguration = runConfiguration;
  this.env = env;
  this.configState = configState;
  this.consoleProvider = new BlazeAndroidBinaryConsoleProvider(project);
  this.buildStep = new BlazeApkBuildStepNormalBuild(project, label, blazeFlags);
  this.apkProvider = new BlazeApkProvider(project, buildStep);
  this.applicationIdProvider = new BlazeAndroidBinaryApplicationIdProvider(buildStep);
}
 
Example #5
Source File: AbstractExternalSystemRuntimeConfigurationProducer.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
protected RunnerAndConfigurationSettings findExistingByElement(Location location,
                                                               @Nonnull List<RunnerAndConfigurationSettings> existingConfigurationsSettings,
                                                               ConfigurationContext context) {
  if (!(location instanceof ExternalSystemTaskLocation)) {
    return null;
  }
  ExternalTaskExecutionInfo taskInfo = ((ExternalSystemTaskLocation)location).getTaskInfo();

  for (RunnerAndConfigurationSettings settings : existingConfigurationsSettings) {
    RunConfiguration runConfiguration = settings.getConfiguration();
    if (!(runConfiguration instanceof ExternalSystemRunConfiguration)) {
      continue;
    }
    if (match(taskInfo, ((ExternalSystemRunConfiguration)runConfiguration).getSettings())) {
      return settings;
    }
  }
  return null;
}
 
Example #6
Source File: GaugeExecutionProducer.java    From Intellij-Plugin with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean setupConfigurationFromContext(RunConfiguration configuration, ConfigurationContext context, Ref sourceElement) {
    VirtualFile[] selectedFiles = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(context.getDataContext());
    if (selectedFiles == null || selectedFiles.length > 1) return false;
    Module module = context.getModule();
    if (context.getPsiLocation() == null || module == null) return false;
    PsiFile file = context.getPsiLocation().getContainingFile();
    if (!isSpecFile(file) || !isInSpecScope(context.getPsiLocation())) return false;
    try {
        VirtualFile virtualFile = file.getVirtualFile();
        if (virtualFile == null) return false;
        String name = virtualFile.getCanonicalPath();
        configuration.setName(file.getName());
        ((GaugeRunConfiguration) configuration).setSpecsToExecute(name);
        ((GaugeRunConfiguration) configuration).setModule(module);
        return true;
    } catch (Exception ex) {
        LOG.debug(ex);
        ex.printStackTrace();
    }
    return true;
}
 
Example #7
Source File: AbstractAutoTestManager.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static List<RunConfiguration> loadConfigurations(State state, Project project) {
  List<RunConfiguration> configurations = ContainerUtil.newArrayList();
  RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(project);
  List<RunConfigurationDescriptor> descriptors = ContainerUtil.notNullize(state.myEnabledRunConfigurations);
  for (RunConfigurationDescriptor descriptor : descriptors) {
    if (descriptor.myType != null && descriptor.myName != null) {
      RunnerAndConfigurationSettings settings = runManager.findConfigurationByTypeAndName(descriptor.myType,
                                                                                          descriptor.myName);
      RunConfiguration configuration = settings != null ? settings.getConfiguration() : null;
      if (configuration != null) {
        configurations.add(configuration);
      }
    }
  }
  return configurations;
}
 
Example #8
Source File: GenerateDeployableJarTaskProvider.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Override
public boolean executeTask(
    DataContext context, RunConfiguration configuration, ExecutionEnvironment env, Task task) {
  Label target = getTarget(configuration);
  if (target == null) {
    return false;
  }

  try {
    File outputJar = getDeployableJar(configuration, env, target);
    LocalFileSystem.getInstance().refreshIoFiles(ImmutableList.of(outputJar));
    ((ApplicationConfiguration) configuration).setVMParameters("-cp " + outputJar.getPath());
    return true;
  } catch (ExecutionException e) {
    ExecutionUtil.handleExecutionError(
        env.getProject(), env.getExecutor().getToolWindowId(), env.getRunProfile(), e);
  }
  return false;
}
 
Example #9
Source File: CompoundRunConfigurationType.java    From consulo with Apache License 2.0 6 votes vote down vote up
public CompoundRunConfigurationType() {
  super("CompoundRunConfigurationType", "Compound", "It runs batch of run configurations at once", ImageEffects.layered(AllIcons.Nodes.Folder, AllIcons.Nodes.RunnableMark));
  addFactory(new ConfigurationFactory(this) {
    @Override
    public RunConfiguration createTemplateConfiguration(Project project) {
      return new CompoundRunConfiguration(project, CompoundRunConfigurationType.this, "Compound Run Configuration");
    }

    @Override
    public String getName() {
      return "Compound Run Configuration";
    }

    @Override
    public boolean isConfigurationSingletonByDefault() {
      return true;
    }

    @Override
    public boolean canConfigurationBeSingleton() {
      return false;
    }
  });
}
 
Example #10
Source File: DeployToServerConfigurationType.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void onNewConfigurationCreated(@Nonnull RunConfiguration configuration) {
  DeployToServerRunConfiguration deployConfiguration = (DeployToServerRunConfiguration)configuration;
  if (deployConfiguration.getServerName() == null) {
    RemoteServer<?> server = ContainerUtil.getFirstItem(RemoteServersManager.getInstance().getServers(myServerType));
    if (server != null) {
      deployConfiguration.setServerName(server.getName());
    }
  }

  if (deployConfiguration.getDeploymentSource() == null) {
    List<DeploymentSource> sources = deployConfiguration.getDeploymentConfigurator().getAvailableDeploymentSources();
    DeploymentSource source = ContainerUtil.getFirstItem(sources);
    if (source != null) {
      deployConfiguration.setDeploymentSource(source);
      DeploymentSourceType type = source.getType();
      type.setBuildBeforeRunTask(configuration, source);
    }
  }
}
 
Example #11
Source File: BaseExecuteBeforeRunDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
private DefaultMutableTreeNode buildNodes() {
  DefaultMutableTreeNode root = new DefaultMutableTreeNode(new Descriptor());
  RunManager runManager = RunManager.getInstance(myProject);
  final ConfigurationType[] configTypes = runManager.getConfigurationFactories();

  for (final ConfigurationType type : configTypes) {
    final Icon icon = TargetAWT.to(type.getIcon());
    DefaultMutableTreeNode typeNode = new DefaultMutableTreeNode(new ConfigurationTypeDescriptor(type, icon, isConfigurationAssigned(type)));
    root.add(typeNode);
    final Set<String> addedNames = new THashSet<>();
    RunConfiguration[] configurations = runManager.getConfigurations(type);
    for (final RunConfiguration configuration : configurations) {
      final String configurationName = configuration.getName();
      if (addedNames.contains(configurationName)) {
        // add only the first configuration if more than one has the same name
        continue;
      }
      addedNames.add(configurationName);
      typeNode.add(new DefaultMutableTreeNode(new ConfigurationDescriptor(configuration, isConfigurationAssigned(configuration))));
    }
  }

  return root;
}
 
Example #12
Source File: ConsoleProps.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private ConsoleProps(@NotNull RunConfiguration config,
                     @NotNull Executor exec,
                     @NotNull DartUrlResolver resolver,
                     String testFrameworkName) {
  super(config, "FlutterTestRunner", exec);
  this.resolver = resolver;
  setUsePredefinedMessageFilter(false);
  setIdBasedTestTree(true);
}
 
Example #13
Source File: RunConfigurationBeforeRunProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected JComponent createCenterPanel() {
  myJBList = new JBList(mySettings);
  myJBList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  myJBList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    @Override
    public void valueChanged(ListSelectionEvent e) {
      Object selectedValue = myJBList.getSelectedValue();
      if (selectedValue instanceof RunnerAndConfigurationSettings) {
        mySelectedSettings = (RunnerAndConfigurationSettings)selectedValue;
      }
      else {
        mySelectedSettings = null;
      }
      setOKActionEnabled(mySelectedSettings != null);
    }
  });
  myJBList.setCellRenderer(new ColoredListCellRenderer() {
    @Override
    protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      if (value instanceof RunnerAndConfigurationSettings) {
        RunnerAndConfigurationSettings settings = (RunnerAndConfigurationSettings)value;
        RunManagerEx runManager = RunManagerEx.getInstanceEx(myProject);
        setIcon(runManager.getConfigurationIcon(settings));
        RunConfiguration configuration = settings.getConfiguration();
        append(configuration.getName(), settings.isTemporary() ? SimpleTextAttributes.GRAY_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES);
      }
    }
  });
  return new JBScrollPane(myJBList);
}
 
Example #14
Source File: AbstractExternalSystemTaskConfigurationType.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected AbstractExternalSystemTaskConfigurationType(@Nonnull final ProjectSystemId externalSystemId) {
  myExternalSystemId = externalSystemId;
  myFactories[0] = new ConfigurationFactory(this) {
    @Override
    public RunConfiguration createTemplateConfiguration(Project project) {
      return doCreateConfiguration(myExternalSystemId, project, this, "");
    }
  };
}
 
Example #15
Source File: BlazeCidrRunConfigurationHandler.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public BlazeCommandRunConfigurationRunner createRunner(
    Executor executor, ExecutionEnvironment environment) {
  RunnerAndConfigurationSettings settings = environment.getRunnerAndConfigurationSettings();
  RunConfiguration config = settings != null ? settings.getConfiguration() : null;
  if (config instanceof BlazeCommandRunConfiguration
      && RunConfigurationUtils.canUseClionRunner((BlazeCommandRunConfiguration) config)) {
    return new BlazeCidrRunConfigurationRunner((BlazeCommandRunConfiguration) config);
  }
  return new BlazeCommandGenericRunConfigurationRunner();
}
 
Example #16
Source File: DeployToServerConfigurationType.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void onNewConfigurationCreated(@Nonnull RunConfiguration configuration) {
  LocalServerRunConfiguration deployConfiguration = (LocalServerRunConfiguration)configuration;

  if (deployConfiguration.getDeploymentSource() == null) {
    List<DeploymentSource> sources = deployConfiguration.getDeploymentConfigurator().getAvailableDeploymentSources();
    DeploymentSource source = ContainerUtil.getFirstItem(sources);
    if (source != null) {
      deployConfiguration.setDeploymentSource(source);
      DeploymentSourceType type = source.getType();
      type.setBuildBeforeRunTask(configuration, source);
    }
  }
}
 
Example #17
Source File: BlazeAndroidBinaryMobileInstallRunContext.java    From intellij with Apache License 2.0 5 votes vote down vote up
public BlazeAndroidBinaryMobileInstallRunContext(
    Project project,
    AndroidFacet facet,
    RunConfiguration runConfiguration,
    ExecutionEnvironment env,
    BlazeAndroidBinaryRunConfigurationState configState,
    Label label,
    ImmutableList<String> blazeFlags,
    ImmutableList<String> exeFlags) {
  super(project, facet, runConfiguration, env, configState, label, blazeFlags, exeFlags);
}
 
Example #18
Source File: BlazeAndroidBinaryNormalBuildRunContext.java    From intellij with Apache License 2.0 5 votes vote down vote up
BlazeAndroidBinaryNormalBuildRunContext(
    Project project,
    AndroidFacet facet,
    RunConfiguration runConfiguration,
    ExecutionEnvironment env,
    BlazeAndroidBinaryRunConfigurationState configState,
    Label label,
    ImmutableList<String> blazeFlags) {
  super(project, facet, runConfiguration, env, configState, label, blazeFlags);
}
 
Example #19
Source File: BlazeAndroidBinaryMobileInstallRunContext.java    From intellij with Apache License 2.0 5 votes vote down vote up
public BlazeAndroidBinaryMobileInstallRunContext(
    Project project,
    AndroidFacet facet,
    RunConfiguration runConfiguration,
    ExecutionEnvironment env,
    BlazeAndroidBinaryRunConfigurationState configState,
    Label label,
    ImmutableList<String> blazeFlags,
    ImmutableList<String> exeFlags) {
  super(project, facet, runConfiguration, env, configState, label, blazeFlags, exeFlags);
}
 
Example #20
Source File: BlazeAutoAndroidDebugger.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public void attachToClient(Project project, Client client, RunConfiguration config) {
  if (isNativeProject(project)) {
    log.info("Project has native development enabled. Attaching native debugger.");
    nativeDebugger.attachToClient(project, client, config);
  } else {
    super.attachToClient(project, client, config);
  }
}
 
Example #21
Source File: ExportTestResultsAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static ExportTestResultsAction create(String toolWindowId, RunConfiguration runtimeConfiguration) {
  ExportTestResultsAction action = new ExportTestResultsAction();
  action.copyFrom(ActionManager.getInstance().getAction(ID));
  action.myToolWindowId = toolWindowId;
  action.myRunConfiguration = runtimeConfiguration;
  return action;
}
 
Example #22
Source File: ConfigurationSettingsEditorWrapper.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void doApply(final RunnerAndConfigurationSettings settings) {
  final RunConfiguration runConfiguration = settings.getConfiguration();
  final RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(runConfiguration.getProject());
  runManager.setBeforeRunTasks(runConfiguration, myBeforeRunStepsPanel.getTasks(true), false);
  RunnerAndConfigurationSettings runManagerSettings = runManager.getSettings(runConfiguration);
  if (runManagerSettings != null) {
    runManagerSettings.setEditBeforeRun(myBeforeRunStepsPanel.needEditBeforeRun());
  }
  else {
    settings.setEditBeforeRun(myBeforeRunStepsPanel.needEditBeforeRun());
  }
}
 
Example #23
Source File: BlazeAndroidRunConfigurationRunner.java    From intellij with Apache License 2.0 5 votes vote down vote up
public BlazeAndroidRunConfigurationRunner(
    Module module,
    BlazeAndroidRunContext runContext,
    BlazeAndroidRunConfigurationDeployTargetManager deployTargetManager,
    BlazeAndroidRunConfigurationDebuggerManager debuggerManager,
    RunConfiguration runConfig) {
  this.module = module;
  this.runContext = runContext;
  this.deployTargetManager = deployTargetManager;
  this.debuggerManager = debuggerManager;
  this.runConfig = runConfig;
}
 
Example #24
Source File: TestRecorderBlazeCommandRunConfigurationTest.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Test
public void testSuitableRunConfigurations() {
  addConfigurations();

  List<RunConfiguration> allConfigurations =
      RunManagerEx.getInstanceEx(getProject()).getAllConfigurationsList();
  assertThat(allConfigurations.size()).isEqualTo(2);

  List<RunConfiguration> suitableConfigurations =
      TestRecorderAction.getSuitableRunConfigurations(getProject());
  assertThat(suitableConfigurations.size()).isEqualTo(1);
  assertThat(suitableConfigurations.get(0).getName()).isEqualTo("AndroidBinaryConfiguration");
}
 
Example #25
Source File: RunConfigurationProducer.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected RunnerAndConfigurationSettings cloneTemplateConfiguration(@Nonnull final ConfigurationContext context) {
  final RunConfiguration original = context.getOriginalConfiguration(myConfigurationFactory.getType());
  if (original != null) {
    return RunManager.getInstance(context.getProject()).createConfiguration(original.clone(), myConfigurationFactory);
  }
  return RunManager.getInstance(context.getProject()).createRunConfiguration("", myConfigurationFactory);
}
 
Example #26
Source File: PendingTargetRunConfigurationHandler.java    From intellij with Apache License 2.0 5 votes vote down vote up
/** #api193: remove when 2019.3 no longer supported; default implementation added in 2020.1. */
@Nullable
@Override
public SettingsEditor<RunnerSettings> getSettingsEditor(
    Executor executor, RunConfiguration runConfiguration) {
  return null;
}
 
Example #27
Source File: SpecsExecutionProducer.java    From Intellij-Plugin with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isConfigurationFromContext(RunConfiguration config, ConfigurationContext context) {
    if (!(config.getType() instanceof GaugeRunTaskConfigurationType)) return false;
    if (!(context.getPsiLocation() instanceof PsiDirectory) && !(context.getPsiLocation() instanceof PsiFile))
        return false;
    VirtualFile[] selectedFiles = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(context.getDataContext());
    if (selectedFiles == null) return false;
    String specs = ((GaugeRunConfiguration) config).getSpecsToExecute();
    return StringUtil.join(getSpecs(selectedFiles), Constants.SPEC_FILE_DELIMITER).equals(specs);
}
 
Example #28
Source File: BlazeBeforeRunTaskProvider.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public Task createTask(RunConfiguration config) {
  if (config instanceof BlazeCommandRunConfiguration) {
    return new Task();
  }
  return null;
}
 
Example #29
Source File: RunConfigurationSerializerTest.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Test
public void testSetKeepInSyncWhenImporting() throws InvalidDataException {
  configuration.setTarget(Label.create("//package:rule"));
  configuration.setKeepInSync(false);

  Element element = RunConfigurationSerializer.writeToXml(configuration);
  assertThat(RunConfigurationSerializer.findExisting(getProject(), element)).isNotNull();

  clearRunManager(); // remove configuration from project
  RunConfigurationSerializer.loadFromXmlElementIgnoreExisting(getProject(), element);

  RunConfiguration config = runManager.getAllConfigurations()[0];
  assertThat(config).isInstanceOf(BlazeCommandRunConfiguration.class);
  assertThat(((BlazeCommandRunConfiguration) config).getKeepInSync()).isTrue();
}
 
Example #30
Source File: BlazeRunConfigurationFactory.java    From intellij with Apache License 2.0 5 votes vote down vote up
/** Constructs and initializes {@link RunnerAndConfigurationSettings} for the given rule. */
public RunnerAndConfigurationSettings createForTarget(
    Project project, RunManager runManager, Label target) {
  ConfigurationFactory factory = getConfigurationFactory();
  RunConfiguration configuration = factory.createTemplateConfiguration(project, runManager);
  setupConfiguration(configuration, target);
  return runManager.createConfiguration(configuration, factory);
}