Search in sources :

Example 81 with ExecutionException

use of com.intellij.execution.ExecutionException in project android by JetBrains.

the class AndroidRunDdmsAction method doLaunchDdms.

private static void doLaunchDdms(GeneralCommandLine commandLine, final Project project, final boolean adbServiceWasEnabled) {
    try {
        ourProcessHandler = new OSProcessHandler(commandLine);
        ourProcessHandler.startNotify();
        ourProcessHandler.waitFor();
    } catch (ExecutionException e) {
        LOG.info(e);
    } finally {
        ourProcessHandler = null;
        if (adbServiceWasEnabled) {
            ApplicationManager.getApplication().invokeLater(new Runnable() {

                @Override
                public void run() {
                    if (project.isDisposed()) {
                        return;
                    }
                    AndroidEnableAdbServiceAction.setAdbServiceEnabled(project, true);
                    // trigger creation of new bridge
                    File adb = AndroidSdkUtils.getAdb(project);
                    if (adb != null) {
                        AdbService.getInstance().getDebugBridge(adb);
                    }
                }
            });
        }
    }
}
Also used : OSProcessHandler(com.intellij.execution.process.OSProcessHandler) ExecutionException(com.intellij.execution.ExecutionException) File(java.io.File)

Example 82 with ExecutionException

use of com.intellij.execution.ExecutionException in project intellij-elixir by KronicDeth.

the class MixBuilder method runMix.

private static void runMix(@NotNull String elixirPath, @NotNull String mixPath, @Nullable String contentRootPath, boolean addDebugInfo, @NotNull CompileContext context) throws ProjectBuildException {
    GeneralCommandLine commandLine = new GeneralCommandLine();
    commandLine.withWorkDirectory(contentRootPath);
    commandLine.setExePath(elixirPath);
    commandLine.addParameter(mixPath);
    commandLine.addParameter("compile");
    if (!addDebugInfo) {
        commandLine.addParameter("--no-debug-info");
    }
    Process process;
    try {
        process = commandLine.createProcess();
    } catch (ExecutionException e) {
        throw new ProjectBuildException("Failed to run mix.", e);
    }
    BaseOSProcessHandler handler = new BaseOSProcessHandler(process, commandLine.getCommandLineString(), Charset.defaultCharset());
    ProcessAdapter adapter = new ElixirCompilerProcessAdapter(context, NAME, commandLine.getWorkDirectory().getPath());
    handler.addProcessListener(adapter);
    handler.startNotify();
    handler.waitFor();
}
Also used : ProjectBuildException(org.jetbrains.jps.incremental.ProjectBuildException) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) ExecutionException(com.intellij.execution.ExecutionException) BaseOSProcessHandler(com.intellij.execution.process.BaseOSProcessHandler)

Example 83 with ExecutionException

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

the class KarmaExecutionSession method createCommandLine.

@NotNull
private GeneralCommandLine createCommandLine(@NotNull NodeJsLocalInterpreter interpreter, int serverPort, @Nullable KarmaConfig config, @NotNull File clientAppFile) throws ExecutionException {
    GeneralCommandLine commandLine = new GeneralCommandLine();
    File configFile = new File(myRunSettings.getConfigPath());
    // looks like it should work with any working directory
    commandLine.setWorkDirectory(configFile.getParentFile());
    commandLine.setCharset(CharsetToolkit.UTF8_CHARSET);
    commandLine.setExePath(interpreter.getInterpreterSystemDependentPath());
    //NodeCommandLineUtil.addNodeOptionsForDebugging(commandLine, Collections.emptyList(), 5858, false, interpreter, true);
    commandLine.addParameter(clientAppFile.getAbsolutePath());
    commandLine.addParameter("--karmaPackageDir=" + myKarmaServer.getServerSettings().getKarmaPackage().getSystemDependentPath());
    commandLine.addParameter("--serverPort=" + serverPort);
    if (config != null) {
        commandLine.addParameter("--urlRoot=" + config.getUrlRoot());
    }
    if (isDebug()) {
        commandLine.addParameter("--debug=true");
    }
    if (myRunSettings.getScopeKind() == KarmaScopeKind.TEST_FILE) {
        List<String> topNames = findTopLevelSuiteNames(myProject, myRunSettings.getTestFileSystemIndependentPath());
        if (topNames.size() > 1) {
            throw new ExecutionException("Cannot run test file with several top level suites");
        }
        topNames = ContainerUtil.map(topNames, s -> s + " ");
        commandLine.addParameter("--testName=" + StringUtil.join(topNames, "|"));
    } else if (myRunSettings.getScopeKind() == KarmaScopeKind.SUITE || myRunSettings.getScopeKind() == KarmaScopeKind.TEST) {
        commandLine.addParameter("--testName=" + StringUtil.join(myRunSettings.getTestNames(), " "));
    }
    return commandLine;
}
Also used : TestProxyFilterProvider(com.intellij.execution.testframework.sm.runner.TestProxyFilterProvider) CharsetToolkit(com.intellij.openapi.vfs.CharsetToolkit) ExecutionException(com.intellij.execution.ExecutionException) SMTestRunnerConnectionUtil(com.intellij.execution.testframework.sm.SMTestRunnerConnectionUtil) VirtualFile(com.intellij.openapi.vfs.VirtualFile) com.intellij.execution.process(com.intellij.execution.process) QUnitFileStructureBuilder(com.intellij.javascript.testFramework.qunit.QUnitFileStructureBuilder) ContainerUtil(com.intellij.util.containers.ContainerUtil) NodeJsLocalInterpreter(com.intellij.javascript.nodejs.interpreter.local.NodeJsLocalInterpreter) PsiManager(com.intellij.psi.PsiManager) QUnitFileStructure(com.intellij.javascript.testFramework.qunit.QUnitFileStructure) KarmaConfig(com.intellij.javascript.karma.KarmaConfig) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) Disposer(com.intellij.openapi.util.Disposer) SMTRunnerConsoleProperties(com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties) Project(com.intellij.openapi.project.Project) PsiFile(com.intellij.psi.PsiFile) JasmineFileStructureBuilder(com.intellij.javascript.testFramework.jasmine.JasmineFileStructureBuilder) Logger(com.intellij.openapi.diagnostic.Logger) JSFile(com.intellij.lang.javascript.psi.JSFile) KarmaServer(com.intellij.javascript.karma.server.KarmaServer) KarmaTestProxyFilterProvider(com.intellij.javascript.karma.tree.KarmaTestProxyFilterProvider) StringUtil(com.intellij.openapi.util.text.StringUtil) JasmineFileStructure(com.intellij.javascript.testFramework.jasmine.JasmineFileStructure) IOException(java.io.IOException) Executor(com.intellij.execution.Executor) SMTestLocator(com.intellij.execution.testframework.sm.runner.SMTestLocator) LocalFileFinder(org.jetbrains.io.LocalFileFinder) File(java.io.File) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) SMTRunnerConsoleView(com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView) TestConsoleProperties(com.intellij.execution.testframework.TestConsoleProperties) KarmaServerTerminatedListener(com.intellij.javascript.karma.server.KarmaServerTerminatedListener) ObjectUtils(com.intellij.util.ObjectUtils) NotNull(org.jetbrains.annotations.NotNull) KarmaScopeKind(com.intellij.javascript.karma.scope.KarmaScopeKind) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) ExecutionException(com.intellij.execution.ExecutionException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiFile(com.intellij.psi.PsiFile) JSFile(com.intellij.lang.javascript.psi.JSFile) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 84 with ExecutionException

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

the class KarmaCoverageProgramRunner method listenForCoverageFile.

private static void listenForCoverageFile(@NotNull ExecutionEnvironment env, @NotNull KarmaServer server) throws ExecutionException {
    KarmaRunConfiguration runConfiguration = (KarmaRunConfiguration) env.getRunProfile();
    CoverageEnabledConfiguration coverageEnabledConfiguration = CoverageEnabledConfiguration.getOrCreate(runConfiguration);
    CoverageHelper.resetCoverageSuit(runConfiguration);
    String coverageFilePath = coverageEnabledConfiguration.getCoverageFilePath();
    if (coverageFilePath != null) {
        KarmaCoveragePeer coveragePeer = server.getCoveragePeer();
        Objects.requireNonNull(coveragePeer);
        coveragePeer.startCoverageSession(new KarmaCoverageSession() {

            @Override
            public void onCoverageSessionFinished(@Nullable File lcovFile) {
                LOG.info("Processing karma coverage file: " + lcovFile);
                UIUtil.invokeLaterIfNeeded(() -> {
                    Project project = env.getProject();
                    if (project.isDisposed())
                        return;
                    if (lcovFile != null) {
                        processLcovInfoFile(lcovFile, coverageFilePath, env, server, runConfiguration);
                    } else {
                        int response = Messages.showYesNoDialog(project, "Cannot find karma test coverage report - lcov.info", "Missing Karma Coverage Report", "Select lcov.info", "Cancel", Messages.getWarningIcon());
                        if (response == Messages.YES) {
                            FileChooser.chooseFile(FileChooserDescriptorFactory.createSingleFileDescriptor(), project, null, null, file -> {
                                File selected = file != null ? VfsUtilCore.virtualToIoFile(file) : null;
                                if (selected != null) {
                                    processLcovInfoFile(selected, coverageFilePath, env, server, runConfiguration);
                                }
                            });
                        }
                    }
                });
            }
        });
    }
}
Also used : KarmaRunConfiguration(com.intellij.javascript.karma.execution.KarmaRunConfiguration) KarmaUtil(com.intellij.javascript.karma.util.KarmaUtil) KarmaRunConfiguration(com.intellij.javascript.karma.execution.KarmaRunConfiguration) UIUtil(com.intellij.util.ui.UIUtil) FileChooserDescriptorFactory(com.intellij.openapi.fileChooser.FileChooserDescriptorFactory) ExecutionException(com.intellij.execution.ExecutionException) CoverageHelper(com.intellij.coverage.CoverageHelper) RunProfileState(com.intellij.execution.configurations.RunProfileState) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) Project(com.intellij.openapi.project.Project) ExecutionResult(com.intellij.execution.ExecutionResult) Messages(com.intellij.openapi.ui.Messages) FileUtil(com.intellij.openapi.util.io.FileUtil) Logger(com.intellij.openapi.diagnostic.Logger) CoverageEnabledConfiguration(com.intellij.execution.configurations.coverage.CoverageEnabledConfiguration) CoverageRunnerData(com.intellij.coverage.CoverageRunnerData) ConfigurationInfoProvider(com.intellij.execution.configurations.ConfigurationInfoProvider) GenericProgramRunner(com.intellij.execution.runners.GenericProgramRunner) VfsUtilCore(com.intellij.openapi.vfs.VfsUtilCore) KarmaServer(com.intellij.javascript.karma.server.KarmaServer) CoverageDataManager(com.intellij.coverage.CoverageDataManager) RunProfile(com.intellij.execution.configurations.RunProfile) FileDocumentManager(com.intellij.openapi.fileEditor.FileDocumentManager) IOException(java.io.IOException) RunnerSettings(com.intellij.execution.configurations.RunnerSettings) File(java.io.File) Objects(java.util.Objects) Nullable(org.jetbrains.annotations.Nullable) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) CoverageExecutor(com.intellij.coverage.CoverageExecutor) ExecutionUtil(com.intellij.execution.runners.ExecutionUtil) KarmaConsoleView(com.intellij.javascript.karma.execution.KarmaConsoleView) NotNull(org.jetbrains.annotations.NotNull) FileChooser(com.intellij.openapi.fileChooser.FileChooser) Project(com.intellij.openapi.project.Project) CoverageEnabledConfiguration(com.intellij.execution.configurations.coverage.CoverageEnabledConfiguration) File(java.io.File)

Example 85 with ExecutionException

use of com.intellij.execution.ExecutionException in project buck by facebook.

the class TestExecutionState method attachDebugger.

private void attachDebugger(String title, String port) {
    final RemoteConnection remoteConnection = new RemoteConnection(/* useSockets */
    true, "localhost", port, /* serverMode */
    false);
    final RemoteStateState state = new RemoteStateState(mProject, remoteConnection);
    final String name = title + " debugger (" + port + ")";
    final ConfigurationFactory cfgFactory = ConfigurationTypeUtil.findConfigurationType("Remote").getConfigurationFactories()[0];
    RunnerAndConfigurationSettings runSettings = RunManager.getInstance(mProject).createRunConfiguration(name, cfgFactory);
    final Executor debugExecutor = DefaultDebugExecutor.getDebugExecutorInstance();
    final ExecutionEnvironment env = new ExecutionEnvironmentBuilder(mProject, debugExecutor).runProfile(runSettings.getConfiguration()).build();
    final int pollTimeout = 3000;
    final DebugEnvironment environment = new DefaultDebugEnvironment(env, state, remoteConnection, pollTimeout);
    ApplicationManager.getApplication().invokeLater(() -> {
        try {
            final DebuggerSession debuggerSession = DebuggerManagerEx.getInstanceEx(mProject).attachVirtualMachine(environment);
            if (debuggerSession == null) {
                return;
            }
            XDebuggerManager.getInstance(mProject).startSessionAndShowTab(name, null, new XDebugProcessStarter() {

                @Override
                @NotNull
                public XDebugProcess start(@NotNull XDebugSession session) {
                    return JavaDebugProcess.create(session, debuggerSession);
                }
            });
        } catch (ExecutionException e) {
            LOG.error("failed to attach to debugger on port " + port + " with polling timeout " + pollTimeout);
        }
    });
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) XDebugProcess(com.intellij.xdebugger.XDebugProcess) NotNull(org.jetbrains.annotations.NotNull) DefaultDebugEnvironment(com.intellij.debugger.DefaultDebugEnvironment) DefaultDebugExecutor(com.intellij.execution.executors.DefaultDebugExecutor) Executor(com.intellij.execution.Executor) DebuggerSession(com.intellij.debugger.impl.DebuggerSession) XDebugProcessStarter(com.intellij.xdebugger.XDebugProcessStarter) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) RemoteConnection(com.intellij.execution.configurations.RemoteConnection) RemoteStateState(com.intellij.debugger.engine.RemoteStateState) ExecutionEnvironmentBuilder(com.intellij.execution.runners.ExecutionEnvironmentBuilder) ExecutionException(com.intellij.execution.ExecutionException) DefaultDebugEnvironment(com.intellij.debugger.DefaultDebugEnvironment) DebugEnvironment(com.intellij.debugger.DebugEnvironment)

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