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