use of com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration in project intellij-community by JetBrains.
the class GradleRerunFailedTestsAction method getRunProfile.
@Nullable
@Override
protected MyRunProfile getRunProfile(@NotNull ExecutionEnvironment environment) {
ExternalSystemRunConfiguration configuration = (ExternalSystemRunConfiguration) myConsoleProperties.getConfiguration();
final List<AbstractTestProxy> failedTests = getFailedTests(configuration.getProject());
return new MyRunProfile(configuration) {
@NotNull
@Override
public Module[] getModules() {
return Module.EMPTY_ARRAY;
}
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException {
ExternalSystemRunConfiguration runProfile = ((ExternalSystemRunConfiguration) getPeer()).clone();
Project project = runProfile.getProject();
Set<String> scriptParameters = ContainerUtil.newLinkedHashSet();
Set<String> tasksToRun = ContainerUtil.newLinkedHashSet();
boolean useResolvedTasks = true;
for (AbstractTestProxy test : failedTests) {
if (test instanceof GradleSMTestProxy) {
String testName = test.getName();
String className = ((GradleSMTestProxy) test).getClassName();
scriptParameters.add(TestMethodGradleConfigurationProducer.createTestFilter(className, testName));
if (!useResolvedTasks)
continue;
if (className == null) {
useResolvedTasks = false;
continue;
}
final PsiClass psiClass = JavaPsiFacade.getInstance(project).findClass(className, GlobalSearchScope.projectScope(project));
if (psiClass == null) {
useResolvedTasks = false;
continue;
}
final PsiFile psiFile = psiClass.getContainingFile();
if (psiFile == null) {
useResolvedTasks = false;
continue;
}
final Module moduleForFile = ProjectFileIndex.SERVICE.getInstance(project).getModuleForFile(psiFile.getVirtualFile());
if (moduleForFile == null) {
useResolvedTasks = false;
continue;
}
ContainerUtil.addAllNotNull(tasksToRun, GradleTestRunConfigurationProducer.getTasksToRun(moduleForFile));
}
}
runProfile.getSettings().setScriptParameters(StringUtil.join(scriptParameters, " "));
if (useResolvedTasks && !tasksToRun.isEmpty()) {
runProfile.getSettings().setTaskNames(ContainerUtil.newArrayList(tasksToRun));
}
return runProfile.getState(executor, environment);
}
};
}
use of com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration in project intellij-community by JetBrains.
the class ExternalSystemUtil method createExternalSystemRunnerAndConfigurationSettings.
@Nullable
public static RunnerAndConfigurationSettings createExternalSystemRunnerAndConfigurationSettings(@NotNull ExternalSystemTaskExecutionSettings taskSettings, @NotNull Project project, @NotNull ProjectSystemId externalSystemId) {
AbstractExternalSystemTaskConfigurationType configurationType = findConfigurationType(externalSystemId);
if (configurationType == null)
return null;
String name = AbstractExternalSystemTaskConfigurationType.generateName(project, taskSettings);
RunnerAndConfigurationSettings settings = RunManager.getInstance(project).createRunConfiguration(name, configurationType.getFactory());
ExternalSystemRunConfiguration runConfiguration = (ExternalSystemRunConfiguration) settings.getConfiguration();
runConfiguration.getSettings().setExternalProjectPath(taskSettings.getExternalProjectPath());
runConfiguration.getSettings().setTaskNames(ContainerUtil.newArrayList(taskSettings.getTaskNames()));
runConfiguration.getSettings().setTaskDescriptions(ContainerUtil.newArrayList(taskSettings.getTaskDescriptions()));
runConfiguration.getSettings().setVmOptions(taskSettings.getVmOptions());
runConfiguration.getSettings().setScriptParameters(taskSettings.getScriptParameters());
runConfiguration.getSettings().setExecutionName(taskSettings.getExecutionName());
return settings;
}
use of com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration in project intellij-community by JetBrains.
the class RunConfigurationNode method update.
@Override
protected void update(PresentationData presentation) {
super.update(presentation);
presentation.setIcon(ProgramRunnerUtil.getConfigurationIcon(mySettings, false));
final ExternalSystemRunConfiguration runConfiguration = (ExternalSystemRunConfiguration) mySettings.getConfiguration();
final ExternalSystemTaskExecutionSettings taskExecutionSettings = runConfiguration.getSettings();
final String shortcutHint = StringUtil.nullize(getShortcutsManager().getDescription(taskExecutionSettings.getExternalProjectPath(), mySettings.getName()));
final String activatorHint = StringUtil.nullize(getTaskActivator().getDescription(taskExecutionSettings.getExternalSystemId(), taskExecutionSettings.getExternalProjectPath(), getRunConfigurationActivationTaskName(mySettings)));
String hint;
if (shortcutHint == null) {
hint = activatorHint;
} else if (activatorHint == null) {
hint = shortcutHint;
} else {
hint = shortcutHint + ", " + activatorHint;
}
setNameAndTooltip(getName(), StringUtil.join(taskExecutionSettings.getTaskNames(), " "), hint);
}
Aggregations