use of com.intellij.execution.ExecutionException in project intellij-community by JetBrains.
the class MavenExternalExecutor method execute.
public boolean execute(final ProgressIndicator indicator) {
displayProgress();
try {
if (myParameterCreationError != null) {
throw myParameterCreationError;
}
myProcessHandler = new OSProcessHandler(myJavaParameters.toCommandLine()) {
@Override
public void notifyTextAvailable(String text, Key outputType) {
// todo move this logic to ConsoleAdapter class
if (!myConsole.isSuppressed(text)) {
super.notifyTextAvailable(text, outputType);
}
updateProgress(indicator, text);
}
};
myConsole.attachToProcess(myProcessHandler);
} catch (ExecutionException e) {
myConsole.systemMessage(MavenServerConsole.LEVEL_FATAL, RunnerBundle.message("external.startup.failed", e.getMessage()), null);
return false;
}
start();
readProcessOutput();
stop();
return printExitSummary();
}
use of com.intellij.execution.ExecutionException in project intellij-community by JetBrains.
the class MavenExternalParameters method getJdk.
@NotNull
private static Sdk getJdk(@Nullable Project project, MavenRunnerSettings runnerSettings, boolean isGlobalRunnerSettings) throws ExecutionException {
String name = runnerSettings.getJreName();
if (name.equals(MavenRunnerSettings.USE_INTERNAL_JAVA)) {
return JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();
}
if (name.equals(MavenRunnerSettings.USE_PROJECT_JDK)) {
if (project != null) {
Sdk res = ProjectRootManager.getInstance(project).getProjectSdk();
if (res != null) {
return res;
}
Module[] modules = ModuleManager.getInstance(project).getModules();
for (Module module : modules) {
Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
if (sdk != null && sdk.getSdkType() instanceof JavaSdkType) {
return sdk;
}
}
}
if (project == null) {
Sdk recent = ProjectJdkTable.getInstance().findMostRecentSdkOfType(JavaSdk.getInstance());
if (recent != null)
return recent;
return JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();
}
throw new ProjectJdkSettingsOpenerExecutionException("Project JDK is not specified. <a href=''>Configure</a>", project);
}
if (name.equals(MavenRunnerSettings.USE_JAVA_HOME)) {
final String javaHome = System.getenv("JAVA_HOME");
if (StringUtil.isEmptyOrSpaces(javaHome)) {
throw new ExecutionException(RunnerBundle.message("maven.java.home.undefined"));
}
final Sdk jdk = JavaSdk.getInstance().createJdk("", javaHome);
if (jdk == null) {
throw new ExecutionException(RunnerBundle.message("maven.java.home.invalid", javaHome));
}
return jdk;
}
for (Sdk projectJdk : ProjectJdkTable.getInstance().getAllJdks()) {
if (projectJdk.getName().equals(name)) {
return projectJdk;
}
}
if (isGlobalRunnerSettings) {
throw new ExecutionException(RunnerBundle.message("maven.java.not.found.default.config", name));
} else {
throw new ExecutionException(RunnerBundle.message("maven.java.not.found", name));
}
}
use of com.intellij.execution.ExecutionException in project intellij-community by JetBrains.
the class PySdkUtil method getProcessOutput.
public static ProcessOutput getProcessOutput(@NotNull GeneralCommandLine cmd, @Nullable String homePath, @Nullable @NonNls Map<String, String> extraEnv, int timeout, @Nullable byte[] stdin, boolean needEOFMarker) {
if (homePath == null || !new File(homePath).exists()) {
return new ProcessOutput();
}
final Map<String, String> systemEnv = System.getenv();
final Map<String, String> expandedCmdEnv = mergeEnvVariables(systemEnv, cmd.getEnvironment());
final Map<String, String> env = extraEnv != null ? mergeEnvVariables(expandedCmdEnv, extraEnv) : expandedCmdEnv;
PythonEnvUtil.resetHomePathChanges(homePath, env);
try {
final GeneralCommandLine commandLine = cmd.withWorkDirectory(homePath).withEnvironment(env);
final CapturingProcessHandler processHandler = new CapturingProcessHandler(commandLine);
if (stdin != null) {
final OutputStream processInput = processHandler.getProcessInput();
assert processInput != null;
processInput.write(stdin);
if (SystemInfo.isWindows && needEOFMarker) {
processInput.write(SUBSTITUTE);
processInput.flush();
} else {
processInput.close();
}
}
return processHandler.runProcess(timeout);
} catch (ExecutionException | IOException e) {
return getOutputForException(e);
}
}
use of com.intellij.execution.ExecutionException in project intellij-community by JetBrains.
the class TestsPattern method createSearchingForTestsTask.
@Override
public SearchForTestsTask createSearchingForTestsTask() {
final JUnitConfiguration.Data data = getConfiguration().getPersistentData();
final Project project = getConfiguration().getProject();
final Set<String> classNames = new LinkedHashSet<>();
for (String className : data.getPatterns()) {
final PsiClass psiClass = getTestClass(project, className);
if (psiClass != null && JUnitUtil.isTestClass(psiClass)) {
classNames.add(className);
}
}
if (classNames.size() == data.getPatterns().size()) {
return new SearchForTestsTask(project, myServerSocket) {
@Override
protected void search() throws ExecutionException {
final Function<String, String> nameFunction = StringUtil.isEmpty(data.METHOD_NAME) ? FunctionUtil.<String>id() : (Function<String, String>) className -> className;
addClassesListToJavaParameters(classNames, nameFunction, "", false, getJavaParameters());
}
@Override
protected void onFound() {
}
};
}
return super.createSearchingForTestsTask();
}
use of com.intellij.execution.ExecutionException in project intellij-community by JetBrains.
the class PyAbstractTestProcessRunner method rerunFailedTests.
/**
* Rerun current tests. Make sure there is at least one failed test.
* <strong>Run in AWT thread only!</strong>
*/
public void rerunFailedTests() {
assert getFailedTestsCount() > 0 : "No failed tests. What you want to rerun?";
assert myLastProcessDescriptor != null : "No last run descriptor. First run tests at least one time";
final List<ProgramRunner<?>> run = getAvailableRunnersForLastRun();
Assert.assertFalse("No runners to rerun", run.isEmpty());
final ProgramRunner<?> runner = run.get(0);
final ExecutionEnvironment restartAction = RerunFailedActionsTestTools.findRestartAction(myLastProcessDescriptor);
Assert.assertNotNull("No restart action", restartAction);
final Ref<ProcessHandler> handlerRef = new Ref<>();
try {
runner.execute(restartAction, descriptor -> handlerRef.set(descriptor.getProcessHandler()));
} catch (final ExecutionException e) {
throw new AssertionError("ExecutionException can't be thrown in tests. Probably, API changed. Got: " + e);
}
final ProcessHandler handler = handlerRef.get();
if (handler == null) {
return;
}
handler.waitFor();
}
Aggregations