Search in sources :

Example 41 with ExecutionException

use of com.intellij.execution.ExecutionException in project intellij-community by JetBrains.

the class PlatformTestUtil method assertSuccessful.

public static void assertSuccessful(@NotNull GeneralCommandLine command) {
    try {
        ProcessOutput output = ExecUtil.execAndGetOutput(command.withRedirectErrorStream(true));
        Assert.assertEquals(output.getStdout(), 0, output.getExitCode());
    } catch (ExecutionException e) {
        throw new RuntimeException(e);
    }
}
Also used : ProcessOutput(com.intellij.execution.process.ProcessOutput) ExecutionException(com.intellij.execution.ExecutionException)

Example 42 with ExecutionException

use of com.intellij.execution.ExecutionException in project intellij-community by JetBrains.

the class ExecutionHandler method runBuild.

@Nullable
private static ProcessHandler runBuild(final ProgressIndicator progress, @NotNull final AntBuildMessageView errorView, @NotNull final AntBuildFileBase buildFile, @NotNull final AntBuildListener antBuildListener, @NotNull GeneralCommandLine commandLine) {
    final Project project = buildFile.getProject();
    final long startTime = System.currentTimeMillis();
    LocalHistory.getInstance().putSystemLabel(project, AntBundle.message("ant.build.local.history.label", buildFile.getName()));
    final AntProcessHandler handler;
    try {
        handler = AntProcessHandler.runCommandLine(commandLine);
    } catch (final ExecutionException e) {
        ApplicationManager.getApplication().invokeLater(() -> ExecutionErrorDialog.show(e, AntBundle.message("could.not.start.process.error.dialog.title"), project));
        antBuildListener.buildFinished(AntBuildListener.FAILED_TO_RUN, 0);
        return null;
    }
    processRunningAnt(progress, handler, errorView, buildFile, startTime, antBuildListener);
    return handler;
}
Also used : Project(com.intellij.openapi.project.Project) ExecutionException(com.intellij.execution.ExecutionException) Nullable(org.jetbrains.annotations.Nullable)

Example 43 with ExecutionException

use of com.intellij.execution.ExecutionException in project intellij-community by JetBrains.

the class DebuggerTestCase method createLocalSession.

protected DebuggerSession createLocalSession(final JavaParameters javaParameters) throws ExecutionException, InterruptedException {
    createBreakpoints(javaParameters.getMainClass());
    DebuggerSettings.getInstance().DEBUGGER_TRANSPORT = DebuggerSettings.SOCKET_TRANSPORT;
    GenericDebuggerRunnerSettings debuggerRunnerSettings = new GenericDebuggerRunnerSettings();
    debuggerRunnerSettings.LOCAL = true;
    final RemoteConnection debugParameters = DebuggerManagerImpl.createDebugParameters(javaParameters, debuggerRunnerSettings, false);
    ExecutionEnvironment environment = new ExecutionEnvironmentBuilder(myProject, DefaultDebugExecutor.getDebugExecutorInstance()).runnerSettings(debuggerRunnerSettings).runProfile(new MockConfiguration()).build();
    final JavaCommandLineState javaCommandLineState = new JavaCommandLineState(environment) {

        @Override
        protected JavaParameters createJavaParameters() {
            return javaParameters;
        }

        @Override
        protected GeneralCommandLine createCommandLine() throws ExecutionException {
            return getJavaParameters().toCommandLine();
        }
    };
    ApplicationManager.getApplication().invokeAndWait(() -> {
        try {
            myDebuggerSession = DebuggerManagerEx.getInstanceEx(myProject).attachVirtualMachine(new DefaultDebugEnvironment(new ExecutionEnvironmentBuilder(myProject, DefaultDebugExecutor.getDebugExecutorInstance()).runProfile(new MockConfiguration()).build(), javaCommandLineState, debugParameters, false));
            XDebuggerManager.getInstance(myProject).startSession(javaCommandLineState.getEnvironment(), new XDebugProcessStarter() {

                @Override
                @NotNull
                public XDebugProcess start(@NotNull XDebugSession session) {
                    return JavaDebugProcess.create(session, myDebuggerSession);
                }
            });
        } catch (ExecutionException e) {
            LOG.error(e);
        }
    });
    myDebugProcess = myDebuggerSession.getProcess();
    myDebugProcess.addProcessListener(new ProcessAdapter() {

        @Override
        public void onTextAvailable(ProcessEvent event, Key outputType) {
            print(event.getText(), outputType);
        }
    });
    assertNotNull(myDebuggerSession);
    assertNotNull(myDebugProcess);
    return myDebuggerSession;
}
Also used : ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent) NotNull(org.jetbrains.annotations.NotNull) ExecutionEnvironmentBuilder(com.intellij.execution.runners.ExecutionEnvironmentBuilder) ExecutionException(com.intellij.execution.ExecutionException) Key(com.intellij.openapi.util.Key)

Example 44 with ExecutionException

use of com.intellij.execution.ExecutionException in project intellij-community by JetBrains.

the class BaseExternalTool method show.

public void show(DiffRequest request) {
    saveContents(request);
    GeneralCommandLine commandLine = new GeneralCommandLine();
    commandLine.setExePath(getToolPath());
    try {
        commandLine.addParameters(getParameters(request));
        commandLine.createProcess();
    } catch (Exception e) {
        ExecutionErrorDialog.show(new ExecutionException(e.getMessage()), DiffBundle.message("cant.launch.diff.tool.error.message"), request.getProject());
    }
}
Also used : GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) ExecutionException(com.intellij.execution.ExecutionException) ExecutionException(com.intellij.execution.ExecutionException)

Example 45 with ExecutionException

use of com.intellij.execution.ExecutionException in project intellij-community by JetBrains.

the class JdkBundle method getJDKNameArchVersionAndUpdate.

private static Pair<Pair<String, Boolean>, Pair<Version, Integer>> getJDKNameArchVersionAndUpdate(File jvm, String homeSubPath) {
    GeneralCommandLine commandLine = new GeneralCommandLine().withParentEnvironmentType(GeneralCommandLine.ParentEnvironmentType.NONE);
    File jvmPath = new File(jvm, homeSubPath + File.separator + "jre" + File.separator + "bin" + File.separator + "java");
    if (!jvmPath.exists()) {
        jvmPath = new File(jvm, homeSubPath + File.separator + "bin" + File.separator + "java");
    }
    commandLine.setExePath(jvmPath.getAbsolutePath());
    commandLine.addParameter("-version");
    String displayVersion;
    Boolean is64Bit = null;
    Pair<Version, Integer> versionAndUpdate = null;
    List<String> outputLines = null;
    try {
        outputLines = ExecUtil.execAndGetOutput(commandLine).getStderrLines();
    } catch (ExecutionException e) {
        // Checking for jdk 6 on mac
        if (SystemInfo.isMac) {
            commandLine.setExePath(new File(jvm, homeSubPath + File.separator + "bin" + File.separator + "java").getAbsolutePath());
            try {
                outputLines = ExecUtil.execAndGetOutput(commandLine).getStderrLines();
            } catch (ExecutionException e1) {
                LOG.debug(e);
            }
        }
        LOG.debug(e);
    }
    if (outputLines != null && outputLines.size() >= 1) {
        String versionLine = outputLines.get(0);
        versionAndUpdate = VersionUtil.parseVersionAndUpdate(versionLine, VERSION_UPDATE_PATTERNS);
        displayVersion = versionLine.replaceFirst("\".*\"", "");
        if (outputLines.size() >= 3) {
            is64Bit = is64BitJVM(outputLines.get(2));
        }
    } else {
        displayVersion = jvm.getName();
    }
    return Pair.create(Pair.create(displayVersion, is64Bit), versionAndUpdate);
}
Also used : GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) ExecutionException(com.intellij.execution.ExecutionException) File(java.io.File)

Aggregations

ExecutionException (com.intellij.execution.ExecutionException)154 NotNull (org.jetbrains.annotations.NotNull)42 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)39 IOException (java.io.IOException)35 File (java.io.File)34 VirtualFile (com.intellij.openapi.vfs.VirtualFile)26 Sdk (com.intellij.openapi.projectRoots.Sdk)20 Nullable (org.jetbrains.annotations.Nullable)20 Project (com.intellij.openapi.project.Project)19 ProcessHandler (com.intellij.execution.process.ProcessHandler)17 ProcessOutput (com.intellij.execution.process.ProcessOutput)17 Module (com.intellij.openapi.module.Module)13 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)12 Key (com.intellij.openapi.util.Key)12 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)10 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)9 ProcessEvent (com.intellij.execution.process.ProcessEvent)8 JavaParameters (com.intellij.execution.configurations.JavaParameters)7 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)7 ArrayList (java.util.ArrayList)7