use of com.intellij.execution.runners.ProgramRunner in project intellij-community by JetBrains.
the class ExternalSystemBeforeRunTaskProvider method executeTask.
@Override
public boolean executeTask(DataContext context, RunConfiguration configuration, ExecutionEnvironment env, ExternalSystemBeforeRunTask beforeRunTask) {
final ExternalSystemTaskExecutionSettings executionSettings = beforeRunTask.getTaskExecutionSettings();
final List<ExternalTaskPojo> tasks = ContainerUtilRt.newArrayList();
for (String taskName : executionSettings.getTaskNames()) {
tasks.add(new ExternalTaskPojo(taskName, executionSettings.getExternalProjectPath(), null));
}
if (tasks.isEmpty())
return true;
ExecutionEnvironment environment = ExternalSystemUtil.createExecutionEnvironment(myProject, mySystemId, executionSettings, DefaultRunExecutor.EXECUTOR_ID);
if (environment == null)
return false;
final ProgramRunner runner = environment.getRunner();
environment.setExecutionId(env.getExecutionId());
return RunConfigurationBeforeRunProvider.doRunTask(DefaultRunExecutor.getRunExecutorInstance().getId(), environment, runner);
}
use of com.intellij.execution.runners.ProgramRunner in project intellij-community by JetBrains.
the class AbstractImportTestsAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final Project project = e.getProject();
LOG.assertTrue(project != null);
final VirtualFile file = getFile(project);
if (file != null) {
try {
final ImportRunProfile profile = new ImportRunProfile(file, project);
SMTRunnerConsoleProperties properties = profile.getProperties();
if (properties == null) {
properties = myProperties;
LOG.info("Failed to detect test framework in " + file.getPath() + "; use " + (properties != null ? properties.getTestFrameworkName() + " from toolbar" : "no properties"));
}
final Executor executor = properties != null ? properties.getExecutor() : ExecutorRegistry.getInstance().getExecutorById(DefaultRunExecutor.EXECUTOR_ID);
ExecutionEnvironmentBuilder builder = ExecutionEnvironmentBuilder.create(project, executor, profile);
ExecutionTarget target = profile.getTarget();
if (target != null) {
builder = builder.target(target);
}
final RunConfiguration initialConfiguration = profile.getInitialConfiguration();
final ProgramRunner runner = initialConfiguration != null ? RunnerRegistry.getInstance().getRunner(executor.getId(), initialConfiguration) : null;
if (runner != null) {
builder = builder.runner(runner);
}
builder.buildAndExecute();
} catch (ExecutionException e1) {
Messages.showErrorDialog(project, e1.getMessage(), "Import Failed");
}
}
}
use of com.intellij.execution.runners.ProgramRunner in project intellij-plugins by JetBrains.
the class CucumberJavaRunConfiguration method getState.
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
return new JavaApplicationCommandLineState<CucumberJavaRunConfiguration>(CucumberJavaRunConfiguration.this, env) {
protected JavaParameters createJavaParameters() throws ExecutionException {
final JavaParameters params = new JavaParameters();
final JavaRunConfigurationModule module = getConfigurationModule();
final int classPathType = JavaParameters.JDK_AND_CLASSES_AND_TESTS;
final String jreHome = CucumberJavaRunConfiguration.this.ALTERNATIVE_JRE_PATH_ENABLED ? ALTERNATIVE_JRE_PATH : null;
JavaParametersUtil.configureModule(module, params, classPathType, jreHome);
JavaParametersUtil.configureConfiguration(params, CucumberJavaRunConfiguration.this);
String path = getSMRunnerPath();
params.getClassPath().add(path);
params.setMainClass(MAIN_CLASS_NAME);
for (RunConfigurationExtension ext : Extensions.getExtensions(RunConfigurationExtension.EP_NAME)) {
ext.updateJavaParameters(CucumberJavaRunConfiguration.this, params, getRunnerSettings());
}
final String glueValue = getGlue();
if (glueValue != null && !StringUtil.isEmpty(glueValue)) {
final String[] glues = glueValue.split(" ");
for (String glue : glues) {
if (!StringUtil.isEmpty(glue)) {
params.getProgramParametersList().addParametersString(" --glue " + glue);
}
}
}
File f = new File(myFilePath);
if (!f.isDirectory()) {
f = f.getParentFile();
}
params.getVMParametersList().addParametersString("-Dorg.jetbrains.run.directory=\"" + f.getAbsolutePath() + "\"");
params.getProgramParametersList().addParametersString("\"" + myFilePath + "\"");
return params;
}
@Nullable
private ConsoleView createConsole(@NotNull final Executor executor, ProcessHandler processHandler) throws ExecutionException {
// console view
final String testFrameworkName = "cucumber";
final CucumberJavaRunConfiguration runConfiguration = CucumberJavaRunConfiguration.this;
final SMTRunnerConsoleProperties consoleProperties = new SMTRunnerConsoleProperties(runConfiguration, testFrameworkName, executor);
return SMTestRunnerConnectionUtil.createAndAttachConsole(testFrameworkName, processHandler, consoleProperties);
}
@NotNull
@Override
public ExecutionResult execute(@NotNull Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
final ProcessHandler processHandler = startProcess();
final ConsoleView console = createConsole(executor, processHandler);
return new DefaultExecutionResult(console, processHandler, createActions(console, processHandler, executor));
}
};
}
use of com.intellij.execution.runners.ProgramRunner in project intellij-community by JetBrains.
the class ToolRunProfile method getState.
@Override
public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) {
final Project project = env.getProject();
if (myCommandLine == null) {
// can return null if creation of cmd line has been cancelled
return null;
}
final CommandLineState commandLineState = new CommandLineState(env) {
GeneralCommandLine createCommandLine() {
return myCommandLine;
}
@Override
@NotNull
protected OSProcessHandler startProcess() throws ExecutionException {
final GeneralCommandLine commandLine = createCommandLine();
final OSProcessHandler processHandler = new ColoredProcessHandler(commandLine);
ProcessTerminatedListener.attach(processHandler);
return processHandler;
}
@Override
@NotNull
public ExecutionResult execute(@NotNull final Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
final ExecutionResult result = super.execute(executor, runner);
final ProcessHandler processHandler = result.getProcessHandler();
if (processHandler != null) {
processHandler.addProcessListener(new ToolProcessAdapter(project, myTool.synchronizeAfterExecution(), getName()));
processHandler.addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
if ((outputType == ProcessOutputTypes.STDOUT && myTool.isShowConsoleOnStdOut()) || (outputType == ProcessOutputTypes.STDERR && myTool.isShowConsoleOnStdErr())) {
ExecutionManager.getInstance(project).getContentManager().toFrontRunContent(executor, processHandler);
}
}
});
}
return result;
}
};
TextConsoleBuilder builder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
final FilterInfo[] outputFilters = myTool.getOutputFilters();
for (FilterInfo outputFilter : outputFilters) {
builder.addFilter(new RegexpFilter(project, outputFilter.getRegExp()));
}
commandLineState.setConsoleBuilder(builder);
return commandLineState;
}
use of com.intellij.execution.runners.ProgramRunner in project intellij-community by JetBrains.
the class CompoundRunConfiguration method getState.
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull final ExecutionEnvironment environment) throws ExecutionException {
try {
checkConfiguration();
} catch (RuntimeConfigurationException e) {
throw new ExecutionException(e.getMessage());
}
return new RunProfileState() {
@Nullable
@Override
public ExecutionResult execute(final Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
ApplicationManager.getApplication().invokeLater(() -> {
RunManagerImpl manager = RunManagerImpl.getInstanceImpl(getProject());
for (RunConfiguration configuration : getSetToRun()) {
RunnerAndConfigurationSettings settings = new RunnerAndConfigurationSettingsImpl(manager, configuration, false);
ExecutionEnvironmentBuilder builder = ExecutionEnvironmentBuilder.createOrNull(executor, settings);
if (builder != null) {
ExecutionManager.getInstance(getProject()).restartRunProfile(builder.activeTarget().dataContext(null).build());
}
}
});
return null;
}
};
}
Aggregations