Search in sources :

Example 1 with BeforeRunTask

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

the class BuildArtifactsBeforeRunTaskProvider method setBuildArtifactBeforeRun.

public static void setBuildArtifactBeforeRun(@NotNull Project project, @NotNull RunConfiguration configuration, @NotNull Artifact artifact) {
    RunManagerEx runManager = RunManagerEx.getInstanceEx(project);
    final List<BuildArtifactsBeforeRunTask> buildArtifactsTasks = runManager.getBeforeRunTasks(configuration, ID);
    if (buildArtifactsTasks.isEmpty()) {
        //Add new task if absent
        BuildArtifactsBeforeRunTask task = new BuildArtifactsBeforeRunTask(project);
        buildArtifactsTasks.add(task);
        List<BeforeRunTask> tasks = runManager.getBeforeRunTasks(configuration);
        tasks.add(task);
        runManager.setBeforeRunTasks(configuration, tasks, false);
    }
    for (BuildArtifactsBeforeRunTask task : buildArtifactsTasks) {
        task.setEnabled(true);
        task.addArtifact(artifact);
    }
}
Also used : BeforeRunTask(com.intellij.execution.BeforeRunTask) RunManagerEx(com.intellij.execution.RunManagerEx)

Example 2 with BeforeRunTask

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

the class BeforeRunStepsPanel method updateText.

private void updateText() {
    StringBuilder sb = new StringBuilder();
    if (myShowSettingsBeforeRunCheckBox.isSelected()) {
        sb.append(ExecutionBundle.message("configuration.edit.before.run"));
    }
    List<BeforeRunTask> tasks = myModel.getItems();
    if (!tasks.isEmpty()) {
        LinkedHashMap<BeforeRunTaskProvider, Integer> counter = new LinkedHashMap<>();
        for (BeforeRunTask task : tasks) {
            BeforeRunTaskProvider<BeforeRunTask> provider = BeforeRunTaskProvider.getProvider(myRunConfiguration.getProject(), task.getProviderId());
            if (provider != null) {
                Integer count = counter.get(provider);
                if (count == null) {
                    count = task.getItemsCount();
                } else {
                    count += task.getItemsCount();
                }
                counter.put(provider, count);
            }
        }
        for (Iterator<Map.Entry<BeforeRunTaskProvider, Integer>> iterator = counter.entrySet().iterator(); iterator.hasNext(); ) {
            Map.Entry<BeforeRunTaskProvider, Integer> entry = iterator.next();
            BeforeRunTaskProvider provider = entry.getKey();
            String name = provider.getName();
            name = StringUtil.trimStart(name, "Run ");
            if (sb.length() > 0) {
                sb.append(", ");
            }
            sb.append(name);
            if (entry.getValue() > 1) {
                sb.append(" (").append(entry.getValue().intValue()).append(")");
            }
        }
    }
    if (myActivateToolWindowBeforeRunCheckBox.isSelected()) {
        sb.append(sb.length() > 0 ? ", " : "").append(ExecutionBundle.message("configuration.activate.toolwindow.before.run"));
    }
    if (sb.length() > 0) {
        sb.insert(0, ": ");
    }
    sb.insert(0, ExecutionBundle.message("before.launch.panel.title"));
    myListener.titleChanged(sb.toString());
}
Also used : BeforeRunTask(com.intellij.execution.BeforeRunTask) BeforeRunTaskProvider(com.intellij.execution.BeforeRunTaskProvider)

Example 3 with BeforeRunTask

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

the class BeforeRunStepsPanel method getSelection.

@Nullable
private Pair<BeforeRunTask, BeforeRunTaskProvider<BeforeRunTask>> getSelection() {
    final int index = myList.getSelectedIndex();
    if (index == -1)
        return null;
    BeforeRunTask task = myModel.getElementAt(index);
    Key providerId = task.getProviderId();
    BeforeRunTaskProvider<BeforeRunTask> provider = BeforeRunTaskProvider.getProvider(myRunConfiguration.getProject(), providerId);
    return provider != null ? Pair.create(task, provider) : null;
}
Also used : BeforeRunTask(com.intellij.execution.BeforeRunTask) Key(com.intellij.openapi.util.Key) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with BeforeRunTask

use of com.intellij.execution.BeforeRunTask in project intellij by bazelbuild.

the class BlazeRunConfigurationSyncListener method enableBlazeBeforeRunTask.

private static boolean enableBlazeBeforeRunTask(RunConfiguration config) {
    boolean changed = false;
    for (BeforeRunTask task : RunManagerCompatUtils.getBeforeRunTasks(config)) {
        if (task.getProviderId().equals(BlazeBeforeRunTaskProvider.ID) && !task.isEnabled()) {
            changed = true;
            task.setEnabled(true);
        }
    }
    return changed;
}
Also used : BeforeRunTask(com.intellij.execution.BeforeRunTask)

Example 5 with BeforeRunTask

use of com.intellij.execution.BeforeRunTask in project google-cloud-intellij by GoogleCloudPlatform.

the class BuildDeploymentSourceType method setBuildBeforeRunTask.

/**
 * Creates a pre-deploy task ({@link BeforeRunTask}) for the given build-system and attaches it to
 * this module deployment source type. Invoked when a new deployment configuration is created.
 *
 * <p>Provides the common functionality for creating the build-system packaging task, delegating
 * build-system specific functions to the concrete sub-types.
 *
 * <p>Only creates a new task if one is not already configured.
 */
@Override
public void setBuildBeforeRunTask(@NotNull RunConfiguration configuration, @NotNull ModuleDeploymentSource source) {
    Module module = source.getModule();
    if (module == null) {
        return;
    }
    setConfiguration(configuration);
    RunManagerEx runManager = RunManagerEx.getInstanceEx(configuration.getProject());
    final Collection<? extends BeforeRunTask> buildTasks = getBuildTasks(runManager, configuration);
    if (!hasBuildTaskForModule(buildTasks, module)) {
        BeforeRunTask buildTask = createBuildTask(module);
        if (buildTask != null) {
            List<BeforeRunTask> tasks = runManager.getBeforeRunTasks(configuration);
            ImmutableList<BeforeRunTask> newTaskList = ImmutableList.<BeforeRunTask>builder().addAll(tasks).add(buildTask).build();
            runManager.setBeforeRunTasks(configuration, newTaskList, true);
        }
    }
}
Also used : BeforeRunTask(com.intellij.execution.BeforeRunTask) RunManagerEx(com.intellij.execution.RunManagerEx) Module(com.intellij.openapi.module.Module)

Aggregations

BeforeRunTask (com.intellij.execution.BeforeRunTask)25 RunManagerEx (com.intellij.execution.RunManagerEx)13 ArrayList (java.util.ArrayList)11 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)9 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)7 Project (com.intellij.openapi.project.Project)6 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)4 MavenBeforeRunTask (org.jetbrains.idea.maven.tasks.MavenBeforeRunTask)3 BeforeRunTaskProvider (com.intellij.execution.BeforeRunTaskProvider)2 UnknownRunConfiguration (com.intellij.execution.configurations.UnknownRunConfiguration)2 ConfigurationSettingsEditorWrapper (com.intellij.execution.impl.ConfigurationSettingsEditorWrapper)2 DataContext (com.intellij.openapi.actionSystem.DataContext)2 Module (com.intellij.openapi.module.Module)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 RuntimeConfigurationError (com.intellij.execution.configurations.RuntimeConfigurationError)1