Search in sources :

Example 11 with RunManagerImpl

use of com.intellij.execution.impl.RunManagerImpl in project android by JetBrains.

the class PostSyncProjectSetup method setMakeStepInJunitRunConfigurations.

private void setMakeStepInJunitRunConfigurations(@NotNull String makeTaskName) {
    ConfigurationType junitConfigurationType = AndroidJUnitConfigurationType.getInstance();
    BeforeRunTaskProvider<BeforeRunTask>[] taskProviders = Extensions.getExtensions(BeforeRunTaskProvider.EXTENSION_POINT_NAME, myProject);
    BeforeRunTaskProvider targetProvider = null;
    for (BeforeRunTaskProvider<? extends BeforeRunTask> provider : taskProviders) {
        if (makeTaskName.equals(provider.getName())) {
            targetProvider = provider;
            break;
        }
    }
    if (targetProvider != null) {
        RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(myProject);
        // Set the correct "Make step" in the "JUnit Run Configuration" template.
        for (ConfigurationFactory configurationFactory : junitConfigurationType.getConfigurationFactories()) {
            RunnerAndConfigurationSettings template = runManager.getConfigurationTemplate(configurationFactory);
            RunConfiguration runConfiguration = template.getConfiguration();
            setMakeStepInJUnitConfiguration(targetProvider, runConfiguration);
        }
        // Set the correct "Make step" in existing JUnit Configurations.
        for (RunConfiguration runConfiguration : runManager.getConfigurationsList(junitConfigurationType)) {
            setMakeStepInJUnitConfiguration(targetProvider, runConfiguration);
        }
    }
}
Also used : ConfigurationType(com.intellij.execution.configurations.ConfigurationType) AndroidJUnitConfigurationType(com.android.tools.idea.testartifacts.junit.AndroidJUnitConfigurationType) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) BeforeRunTaskProvider(com.intellij.execution.BeforeRunTaskProvider) MakeBeforeRunTaskProvider(com.android.tools.idea.gradle.run.MakeBeforeRunTaskProvider) RunManagerImpl(com.intellij.execution.impl.RunManagerImpl)

Example 12 with RunManagerImpl

use of com.intellij.execution.impl.RunManagerImpl in project android by JetBrains.

the class PostSyncProjectSetup method setMakeStepInJUnitConfiguration.

private void setMakeStepInJUnitConfiguration(@NotNull BeforeRunTaskProvider targetProvider, @NotNull RunConfiguration runConfiguration) {
    // Only "make" steps of beforeRunTasks should be overridden (see http://b.android.com/194704 and http://b.android.com/227280)
    List<BeforeRunTask> newBeforeRunTasks = new LinkedList<>();
    RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(myProject);
    for (BeforeRunTask beforeRunTask : runManager.getBeforeRunTasks(runConfiguration)) {
        if (beforeRunTask.getProviderId().equals(CompileStepBeforeRun.ID)) {
            BeforeRunTask task = targetProvider.createTask(runConfiguration);
            if (task != null) {
                task.setEnabled(true);
                newBeforeRunTasks.add(task);
            }
        } else {
            newBeforeRunTasks.add(beforeRunTask);
        }
    }
    runManager.setBeforeRunTasks(runConfiguration, newBeforeRunTasks, false);
}
Also used : BeforeRunTask(com.intellij.execution.BeforeRunTask) LinkedList(java.util.LinkedList) RunManagerImpl(com.intellij.execution.impl.RunManagerImpl)

Aggregations

RunManagerImpl (com.intellij.execution.impl.RunManagerImpl)12 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)4 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)3 ConfigurationType (com.intellij.execution.configurations.ConfigurationType)3 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)3 DefaultRunExecutor (com.intellij.execution.executors.DefaultRunExecutor)2 RunnerAndConfigurationSettingsImpl (com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl)2 Module (com.intellij.openapi.module.Module)2 Project (com.intellij.openapi.project.Project)2 NotNull (org.jetbrains.annotations.NotNull)2 MakeBeforeRunTaskProvider (com.android.tools.idea.gradle.run.MakeBeforeRunTaskProvider)1 AndroidJUnitConfigurationType (com.android.tools.idea.testartifacts.junit.AndroidJUnitConfigurationType)1 BeforeRunTask (com.intellij.execution.BeforeRunTask)1 BeforeRunTaskProvider (com.intellij.execution.BeforeRunTaskProvider)1 UnknownConfigurationType (com.intellij.execution.configurations.UnknownConfigurationType)1 EditConfigurationsDialog (com.intellij.execution.impl.EditConfigurationsDialog)1 ExecutionManagerImpl (com.intellij.execution.impl.ExecutionManagerImpl)1 ExecutionEnvironmentBuilder (com.intellij.execution.runners.ExecutionEnvironmentBuilder)1 ProgramRunner (com.intellij.execution.runners.ProgramRunner)1 AppPropertiesComponentImpl (com.intellij.ide.util.AppPropertiesComponentImpl)1