Search in sources :

Example 46 with ExecutionException

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

the class DartCoverageProgramRunner method startCollectingCoverage.

private static void startCollectingCoverage(@NotNull final ExecutionEnvironment env, @NotNull final ProcessHandler dartAppProcessHandler, @NotNull final String observatoryUrl) {
    final DartCommandLineRunConfiguration dartRC = (DartCommandLineRunConfiguration) env.getRunProfile();
    final DartCoverageEnabledConfiguration coverageConfiguration = (DartCoverageEnabledConfiguration) CoverageEnabledConfiguration.getOrCreate(dartRC);
    final String coverageFilePath = coverageConfiguration.getCoverageFilePath();
    final DartSdk sdk = DartSdk.getDartSdk(env.getProject());
    LOG.assertTrue(sdk != null);
    final GeneralCommandLine cmdline = new GeneralCommandLine().withExePath(DartSdkUtil.getPubPath(sdk)).withParameters("global", "run", "coverage:collect_coverage", "--uri", observatoryUrl, "--out", coverageFilePath, "--resume-isolates", "--wait-paused");
    try {
        final ProcessHandler coverageProcess = new OSProcessHandler(cmdline);
        coverageProcess.addProcessListener(new ProcessAdapter() {

            @Override
            public void onTextAvailable(@NotNull final ProcessEvent event, @NotNull final Key outputType) {
                LOG.debug(event.getText());
            }
        });
        coverageProcess.startNotify();
        coverageConfiguration.setCoverageProcess(coverageProcess);
        CoverageHelper.attachToProcess(dartRC, dartAppProcessHandler, env.getRunnerSettings());
    } catch (ExecutionException e) {
        LOG.error(e);
    }
}
Also used : DartSdk(com.jetbrains.lang.dart.sdk.DartSdk) DartCommandLineRunConfiguration(com.jetbrains.lang.dart.ide.runner.server.DartCommandLineRunConfiguration) ExecutionException(com.intellij.execution.ExecutionException) Key(com.intellij.openapi.util.Key)

Example 47 with ExecutionException

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

the class DartCoverageProgramRunner method activateCoverage.

private boolean activateCoverage(@NotNull final Project project, @NotNull final String dartPubPath) {
    ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
        final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
        if (indicator != null) {
            indicator.setIndeterminate(true);
        }
        try {
            // 'pub global list' is fast, let's run it first to find out if coverage package is already activated.
            // Following 'pub global activate' is long and may be cancelled by user
            checkIfCoverageActivated(dartPubPath);
            // run 'pub global activate' regardless of activation status, because it checks for the coverage package update
            final ProcessOutput activateOutput = new CapturingProcessHandler(new GeneralCommandLine().withExePath(dartPubPath).withParameters("global", "activate", "coverage").withRedirectErrorStream(true)).runProcessWithProgressIndicator(ProgressManager.getInstance().getProgressIndicator());
            if (activateOutput.getExitCode() != 0) {
                LOG.warn("'pub global activate coverage' exit code: " + activateOutput.getExitCode() + ", stdout:\n" + activateOutput.getStdout());
            }
            if (!myCoveragePackageActivated) {
                checkIfCoverageActivated(dartPubPath);
            }
        } catch (ExecutionException e) {
            LOG.warn(e);
        }
    }, "Activating Coverage Package...", true, project);
    // Even if 'pub global activate' process has been cancelled we can proceed if coverage already activated
    return myCoveragePackageActivated;
}
Also used : ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) ExecutionException(com.intellij.execution.ExecutionException)

Example 48 with ExecutionException

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

the class Reveal method refreshRevealPreOnePointSix.

private static void refreshRevealPreOnePointSix(@NotNull String bundleID, @Nullable String deviceName) throws ExecutionException {
    // Pre Reveal 1.6, the refresh script was not bundled with the application
    String script = "activate\n" + "repeat with doc in documents\n" + " refresh doc " + "   application bundle identifier \"" + StringUtil.escapeQuotes(bundleID) + "\"";
    if (deviceName != null) {
        script += "   device name \"" + StringUtil.escapeQuotes(deviceName) + "\"";
    }
    script += "   when available\n" + "end repeat\n" + "activate\n";
    try {
        AppleScript.tell("Reveal", script, true);
    } catch (IdeScriptException e) {
        LOG.info("Reveal script failed:\n" + script);
        throw new ExecutionException("Cannot refresh Reveal: " + e.getMessage(), e);
    }
}
Also used : IdeScriptException(org.jetbrains.ide.script.IdeScriptException) ExecutionException(com.intellij.execution.ExecutionException)

Example 49 with ExecutionException

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

the class RevealRunConfigurationExtension method signAndInstall.

@NotNull
private static File signAndInstall(@NotNull File libReveal, @NotNull final BuildConfiguration buildConfiguration, @NotNull File mainExecutable) throws ExecutionException {
    File frameworksDir = new File(mainExecutable.getParent(), "Frameworks");
    File libRevealCopy = new File(frameworksDir, libReveal.getName());
    try {
        FileUtil.copy(libReveal, libRevealCopy);
    } catch (IOException e) {
        throw new ExecutionException("Cannot create a temporary copy of Reveal library", e);
    }
    AppCodeInstaller.codesignBinary(buildConfiguration, mainExecutable, frameworksDir.getAbsolutePath(), libRevealCopy.getName());
    return new File("Frameworks", libRevealCopy.getName());
}
Also used : IOException(java.io.IOException) ExecutionException(com.intellij.execution.ExecutionException) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 50 with ExecutionException

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

the class RevealRunConfigurationExtension method getBundleID.

@NotNull
private static String getBundleID(@NotNull ExecutionEnvironment environment, @NotNull File product) throws ExecutionException {
    String result = environment.getUserData(BUNDLE_ID_KEY);
    if (result != null)
        return result;
    File plistFile = new File(product, "Info.plist");
    Plist plist = PlistDriver.readAnyFormatSafe(plistFile);
    if (plist == null)
        throw new ExecutionException("Info.plist not found at " + plistFile);
    result = plist.getString("CFBundleIdentifier");
    if (result == null)
        throw new ExecutionException("CFBundleIdentifier not found in " + plistFile);
    environment.putUserData(BUNDLE_ID_KEY, result);
    return result;
}
Also used : Plist(com.jetbrains.cidr.xcode.plist.Plist) ExecutionException(com.intellij.execution.ExecutionException) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

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