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);
}
}
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());
}
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;
}
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;
}
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);
}
}
}
Aggregations