Search in sources :

Example 6 with BeforeRunTask

use of com.intellij.execution.BeforeRunTask in project intellij-community by JetBrains.

the class CompoundRunConfigurationSettingsEditor method canBeAdded.

private boolean canBeAdded(@NotNull RunConfiguration candidate, @NotNull final CompoundRunConfiguration root) {
    if (candidate.getType() == root.getType() && candidate.getName().equals(root.getName()))
        return false;
    List<BeforeRunTask> tasks = myRunManager.getBeforeRunTasks(candidate);
    for (BeforeRunTask task : tasks) {
        if (task instanceof RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask) {
            RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask runTask = (RunConfigurationBeforeRunProvider.RunConfigurableBeforeRunTask) task;
            RunnerAndConfigurationSettings settings = runTask.getSettings();
            if (settings != null) {
                if (!canBeAdded(settings.getConfiguration(), root))
                    return false;
            }
        }
    }
    if (candidate instanceof CompoundRunConfiguration) {
        Set<RunConfiguration> set = ((CompoundRunConfiguration) candidate).getSetToRun();
        for (RunConfiguration configuration : set) {
            if (!canBeAdded(configuration, root))
                return false;
        }
    }
    return true;
}
Also used : BeforeRunTask(com.intellij.execution.BeforeRunTask) RunConfigurationBeforeRunProvider(com.intellij.execution.impl.RunConfigurationBeforeRunProvider) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings)

Example 7 with BeforeRunTask

use of com.intellij.execution.BeforeRunTask 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)

Example 8 with BeforeRunTask

use of com.intellij.execution.BeforeRunTask in project android by JetBrains.

the class ApplicationRunParameters method addOrRemoveMakeTask.

private void addOrRemoveMakeTask(boolean add) {
    final DataContext dataContext = DataManager.getInstance().getDataContext(myPanel);
    final ConfigurationSettingsEditorWrapper editor = ConfigurationSettingsEditorWrapper.CONFIGURATION_EDITOR_KEY.getData(dataContext);
    if (editor == null) {
        return;
    }
    final List<BeforeRunTask> makeTasks = new ArrayList<BeforeRunTask>();
    for (BeforeRunTask task : editor.getStepsBeforeLaunch()) {
        if (task instanceof CompileStepBeforeRun.MakeBeforeRunTask || task instanceof CompileStepBeforeRunNoErrorCheck.MakeBeforeRunTaskNoErrorCheck) {
            makeTasks.add(task);
        }
    }
    if (add) {
        if (makeTasks.size() == 0) {
            editor.addBeforeLaunchStep(new CompileStepBeforeRun.MakeBeforeRunTask());
        } else {
            for (BeforeRunTask task : makeTasks) {
                task.setEnabled(true);
            }
        }
    } else {
        for (BeforeRunTask task : makeTasks) {
            task.setEnabled(false);
        }
    }
}
Also used : BeforeRunTask(com.intellij.execution.BeforeRunTask) DataContext(com.intellij.openapi.actionSystem.DataContext) CompileStepBeforeRun(com.intellij.compiler.options.CompileStepBeforeRun) CompileStepBeforeRunNoErrorCheck(com.intellij.compiler.options.CompileStepBeforeRunNoErrorCheck) ConfigurationSettingsEditorWrapper(com.intellij.execution.impl.ConfigurationSettingsEditorWrapper)

Example 9 with BeforeRunTask

use of com.intellij.execution.BeforeRunTask in project android by JetBrains.

the class PostSyncProjectSetupTest method testJUnitRunConfigurationSetup.

public void testJUnitRunConfigurationSetup() {
    when(myIdeInfo.isAndroidStudio()).thenReturn(true);
    PostSyncProjectSetup.Request request = new PostSyncProjectSetup.Request();
    mySetup.setUpProject(request, myProgressIndicator);
    ConfigurationFactory configurationFactory = AndroidJUnitConfigurationType.getInstance().getConfigurationFactories()[0];
    AndroidJUnitConfiguration jUnitConfiguration = new AndroidJUnitConfiguration("", getProject(), configurationFactory);
    myRunManager.addConfiguration(myRunManager.createConfiguration(jUnitConfiguration, configurationFactory), true);
    List<RunConfiguration> junitRunConfigurations = myRunManager.getConfigurationsList(AndroidJUnitConfigurationType.getInstance());
    for (RunConfiguration runConfiguration : junitRunConfigurations) {
        assertSize(1, myRunManager.getBeforeRunTasks(runConfiguration));
        assertEquals(MakeBeforeRunTaskProvider.ID, myRunManager.getBeforeRunTasks(runConfiguration).get(0).getProviderId());
    }
    RunConfiguration runConfiguration = junitRunConfigurations.get(0);
    List<BeforeRunTask> tasks = new LinkedList<>(myRunManager.getBeforeRunTasks(runConfiguration));
    BeforeRunTask newTask = new MakeBeforeRunTaskProvider(getProject()).createTask(runConfiguration);
    newTask.setEnabled(true);
    tasks.add(newTask);
    myRunManager.setBeforeRunTasks(runConfiguration, tasks, false);
    mySetup.setUpProject(request, myProgressIndicator);
    assertSize(2, myRunManager.getBeforeRunTasks(runConfiguration));
}
Also used : BeforeRunTask(com.intellij.execution.BeforeRunTask) MakeBeforeRunTaskProvider(com.android.tools.idea.gradle.run.MakeBeforeRunTaskProvider) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) AndroidJUnitConfiguration(com.android.tools.idea.testartifacts.junit.AndroidJUnitConfiguration) LinkedList(java.util.LinkedList)

Aggregations

BeforeRunTask (com.intellij.execution.BeforeRunTask)9 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)4 BeforeRunTaskProvider (com.intellij.execution.BeforeRunTaskProvider)2 UnknownRunConfiguration (com.intellij.execution.configurations.UnknownRunConfiguration)2 Key (com.intellij.openapi.util.Key)2 LinkedList (java.util.LinkedList)2 MakeBeforeRunTaskProvider (com.android.tools.idea.gradle.run.MakeBeforeRunTaskProvider)1 AndroidJUnitConfiguration (com.android.tools.idea.testartifacts.junit.AndroidJUnitConfiguration)1 CompileStepBeforeRun (com.intellij.compiler.options.CompileStepBeforeRun)1 CompileStepBeforeRunNoErrorCheck (com.intellij.compiler.options.CompileStepBeforeRunNoErrorCheck)1 RunManagerEx (com.intellij.execution.RunManagerEx)1 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)1 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)1 ConfigurationSettingsEditorWrapper (com.intellij.execution.impl.ConfigurationSettingsEditorWrapper)1 RunConfigurationBeforeRunProvider (com.intellij.execution.impl.RunConfigurationBeforeRunProvider)1 RunManagerImpl (com.intellij.execution.impl.RunManagerImpl)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)1