com.intellij.execution.ExecutionException Java Examples

The following examples show how to use com.intellij.execution.ExecutionException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BlazeAndroidTestRunContext.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings({"unchecked", "rawtypes"}) // Raw type from upstream.
public DebugConnectorTask getDebuggerTask(
    AndroidDebugger androidDebugger,
    AndroidDebuggerState androidDebuggerState,
    Set<String> packageIds)
    throws ExecutionException {
  switch (configState.getLaunchMethod()) {
    case BLAZE_TEST:
      return new ConnectBlazeTestDebuggerTask(
          env.getProject(), androidDebugger, packageIds, applicationIdProvider, this);
    case NON_BLAZE:
    case MOBILE_INSTALL:
      return AndroidDebuggerCompat.getConnectDebuggerTask(
          androidDebugger,
          env,
          null,
          packageIds,
          facet,
          androidDebuggerState,
          runConfiguration.getType().getId());
  }
  throw new AssertionError();
}
 
Example #2
Source File: TestLaunchState.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
static TestLaunchState create(@NotNull ExecutionEnvironment env, @NotNull TestConfig config) throws ExecutionException {
  final TestFields fields = config.getFields();
  try {
    fields.checkRunnable(env.getProject());
  }
  catch (RuntimeConfigurationError e) {
    throw new ExecutionException(e);
  }
  FileDocumentManager.getInstance().saveAllDocuments();

  final VirtualFile fileOrDir = fields.getFileOrDir();
  assert (fileOrDir != null);

  final PubRoot pubRoot = fields.getPubRoot(env.getProject());
  assert (pubRoot != null);

  final FlutterSdk sdk = FlutterSdk.getFlutterSdk(env.getProject());
  assert (sdk != null);
  final boolean testConsoleEnabled = sdk.getVersion().flutterTestSupportsMachineMode();

  final TestLaunchState launcher = new TestLaunchState(env, config, fileOrDir, pubRoot, testConsoleEnabled);
  DaemonConsoleView.install(launcher, env, pubRoot.getRoot());
  return launcher;
}
 
Example #3
Source File: FastBuildConfigurationRunner.java    From intellij with Apache License 2.0 6 votes vote down vote up
private static void handleJavacError(
    ExecutionEnvironment env,
    Project project,
    Label label,
    FastBuildService buildService,
    FastBuildIncrementalCompileException e) {

  BlazeConsoleService console = BlazeConsoleService.getInstance(project);
  console.print(e.getMessage() + "\n", ConsoleViewContentType.ERROR_OUTPUT);
  console.printHyperlink(
      "Click here to run the tests again with a fresh "
          + Blaze.getBuildSystem(project)
          + " build.\n",
      new RerunTestsWithBlazeHyperlink(buildService, label, env));
  ExecutionUtil.handleExecutionError(
      env, new ExecutionException("See the Blaze Console for javac output", e.getCause()));
}
 
Example #4
Source File: OpenInXcodeAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static void openWithXcode(String path) {
  try {
    final GeneralCommandLine cmd = new GeneralCommandLine().withExePath("open").withParameters(path);
    final OSProcessHandler handler = new OSProcessHandler(cmd);
    handler.addProcessListener(new ProcessAdapter() {
      @Override
      public void processTerminated(@NotNull final ProcessEvent event) {
        if (event.getExitCode() != 0) {
          FlutterMessages.showError("Error Opening", path);
        }
      }
    });
    handler.startNotify();
  }
  catch (ExecutionException ex) {
    FlutterMessages.showError(
      "Error Opening",
      "Exception: " + ex.getMessage());
  }
}
 
Example #5
Source File: LaunchCommandsTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void failsForTestNameWithoutTestScript() {
  final BazelTestFields fields = new FakeBazelTestFields(
    BazelTestFields.forTestName("first test", "/workspace/foo/test/foo_test.dart", null),
    "scripts/daemon.sh",
    "scripts/doctor.sh",
    "scripts/launch.sh",
    null,
    null,
    null
  );
  boolean didThrow = false;
  try {
    final GeneralCommandLine launchCommand = fields.getLaunchCommand(projectFixture.getProject(), RunMode.RUN);
  }
  catch (ExecutionException e) {
    didThrow = true;
  }
  assertTrue("This test method expected to throw an exception, but did not.", didThrow);
}
 
Example #6
Source File: FlutterConsoleFilter.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void navigate(Project project) {
  try {
    final GeneralCommandLine cmd = new GeneralCommandLine().withExePath("open").withParameters(myPath);
    final OSProcessHandler handler = new OSProcessHandler(cmd);
    handler.addProcessListener(new ProcessAdapter() {
      @Override
      public void processTerminated(@NotNull final ProcessEvent event) {
        if (event.getExitCode() != 0) {
          FlutterMessages.showError("Error Opening ", myPath);
        }
      }
    });
    handler.startNotify();
  }
  catch (ExecutionException e) {
    FlutterMessages.showError(
      "Error Opening External File",
      "Exception: " + e.getMessage());
  }
}
 
Example #7
Source File: BlazeIntellijPluginDeployer.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Nullable
private static String readPluginIdFromJar(String buildNumber, File jar)
    throws ExecutionException {
  IdeaPluginDescriptor pluginDescriptor = PluginManagerCore.loadDescriptor(jar, "plugin.xml");
  if (pluginDescriptor == null) {
    return null;
  }
  if (PluginManagerCore.isIncompatible(pluginDescriptor, BuildNumber.fromString(buildNumber))) {
    throw new ExecutionException(
        String.format(
            "Plugin SDK version '%s' is incompatible with this plugin "
                + "(since: '%s', until: '%s')",
            buildNumber, pluginDescriptor.getSinceBuild(), pluginDescriptor.getUntilBuild()));
  }
  return pluginDescriptor.getPluginId().getIdString();
}
 
Example #8
Source File: LaunchCommandsTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void runsInFileModeWhenBothFileAndBazelTargetAreProvided() throws ExecutionException {
  final BazelTestFields fields = new FakeBazelTestFields(
    new BazelTestFields(null, "/workspace/foo/test/foo_test.dart", "//foo:test", "--arg1 --arg2 3")
  );
  final GeneralCommandLine launchCommand = fields.getLaunchCommand(projectFixture.getProject(), RunMode.RUN);

  final List<String> expectedCommandLine = new ArrayList<>();
  expectedCommandLine.add("/workspace/scripts/flutter-test.sh");
  expectedCommandLine.add("--arg1");
  expectedCommandLine.add("--arg2");
  expectedCommandLine.add("3");
  expectedCommandLine.add("--no-color");
  expectedCommandLine.add("--machine");
  expectedCommandLine.add("foo/test/foo_test.dart");
  assertThat(launchCommand.getCommandLineList(null), equalTo(expectedCommandLine));
}
 
Example #9
Source File: CabalJspInterface.java    From intellij-haskforce with Apache License 2.0 6 votes vote down vote up
private GeneralCommandLine getCommandLine(String command, String... args) throws IOException, ExecutionException {
    GeneralCommandLine commandLine = new GeneralCommandLine();
    commandLine.setWorkDirectory(myCabalFile.getParentFile().getCanonicalPath());
    commandLine.setExePath(myBuildOptions.myCabalPath);
    ParametersList parametersList = commandLine.getParametersList();
    parametersList.add("--with-ghc=" + myBuildOptions.myGhcPath);
    parametersList.add(command);
    if (command.equals("install") || command.equals("configure")) {
        if (myBuildOptions.myEnableTests) {
            parametersList.add("--enable-tests");
        }
        if (!myBuildOptions.myProfilingBuild) {
            parametersList.add("--disable-library-profiling");
        }
    }
    parametersList.addAll(args);
    commandLine.setRedirectErrorStream(true);
    return commandLine;
}
 
Example #10
Source File: GenerateDeployableJarTaskProvider.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Override
public boolean executeTask(
    DataContext context, RunConfiguration configuration, ExecutionEnvironment env, Task task) {
  Label target = getTarget(configuration);
  if (target == null) {
    return false;
  }

  try {
    File outputJar = getDeployableJar(configuration, env, target);
    LocalFileSystem.getInstance().refreshIoFiles(ImmutableList.of(outputJar));
    ((ApplicationConfiguration) configuration).setVMParameters("-cp " + outputJar.getPath());
    return true;
  } catch (ExecutionException e) {
    ExecutionUtil.handleExecutionError(
        env.getProject(), env.getExecutor().getToolWindowId(), env.getRunProfile(), e);
  }
  return false;
}
 
Example #11
Source File: RunAnythingCommandProvider.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static void runCommand(@Nonnull VirtualFile workDirectory, @Nonnull String commandString, @Nonnull Executor executor, @Nonnull DataContext dataContext) {
  final Project project = dataContext.getData(CommonDataKeys.PROJECT);
  LOG.assertTrue(project != null);

  Collection<String> commands = RunAnythingCache.getInstance(project).getState().getCommands();
  commands.remove(commandString);
  commands.add(commandString);

  dataContext = RunAnythingCommandCustomizer.customizeContext(dataContext);

  GeneralCommandLine initialCommandLine = new GeneralCommandLine(ParametersListUtil.parse(commandString, false, true)).withParentEnvironmentType(GeneralCommandLine.ParentEnvironmentType.CONSOLE).withWorkDirectory(workDirectory.getPath());

  GeneralCommandLine commandLine = RunAnythingCommandCustomizer.customizeCommandLine(dataContext, workDirectory, initialCommandLine);
  try {
    RunAnythingRunProfile runAnythingRunProfile = new RunAnythingRunProfile(Registry.is("run.anything.use.pty", false) ? new PtyCommandLine(commandLine) : commandLine, commandString);
    ExecutionEnvironmentBuilder.create(project, executor, runAnythingRunProfile).dataContext(dataContext).buildAndExecute();
  }
  catch (ExecutionException e) {
    LOG.warn(e);
    Messages.showInfoMessage(project, e.getMessage(), IdeBundle.message("run.anything.console.error.title"));
  }
}
 
Example #12
Source File: PantsCompileOptionsExecutor.java    From intellij-pants-plugin with Apache License 2.0 6 votes vote down vote up
@NotNull
private static String loadProjectStructureFromScript(
  @NotNull String scriptPath,
  @NotNull Consumer<String> statusConsumer,
  @Nullable ProcessAdapter processAdapter
) throws IOException, ExecutionException {
  final GeneralCommandLine commandLine = PantsUtil.defaultCommandLine(scriptPath);
  commandLine.setExePath(scriptPath);
  statusConsumer.consume("Executing " + PathUtil.getFileName(scriptPath));
  final ProcessOutput processOutput = PantsUtil.getCmdOutput(commandLine, processAdapter);
  if (processOutput.checkSuccess(LOG)) {
    return processOutput.getStdout();
  }
  else {
    throw new PantsExecutionException("Failed to update the project!", scriptPath, processOutput);
  }
}
 
Example #13
Source File: BaseExternalTool.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void show(DiffRequest request) {
  for (DiffContent diffContent : request.getContents()) {
    Document document = diffContent.getDocument();
    if (document != null) {
      FileDocumentManager.getInstance().saveDocument(document);
    }
  }
  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());
  }
}
 
Example #14
Source File: LaunchCommandsTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void failsForFileWithoutTestScript() {
  final BazelTestFields fields = new FakeBazelTestFields(
    BazelTestFields.forFile("/workspace/foo/test/foo_test.dart", null),
    "scripts/daemon.sh",
    "scripts/doctor.sh",
    "scripts/launch.sh",
    null,
    null,
    null
  );
  boolean didThrow = false;
  try {
    final GeneralCommandLine launchCommand = fields.getLaunchCommand(projectFixture.getProject(), RunMode.RUN);
  }
  catch (ExecutionException e) {
    didThrow = true;
  }
  assertTrue("This test method expected to throw an exception, but did not.", didThrow);
}
 
Example #15
Source File: WSLDistribution.java    From consulo with Apache License 2.0 6 votes vote down vote up
/**
 * @return identification data of WSL distribution.
 */
@Nullable
public String readReleaseInfo() {
  try {
    final String key = "PRETTY_NAME";
    final String releaseInfo = "/etc/os-release"; // available for all distributions
    final ProcessOutput output = executeOnWsl(10000, "cat", releaseInfo);
    if (LOG.isDebugEnabled()) LOG.debug("Reading release info: " + getId());
    if (!output.checkSuccess(LOG)) return null;
    for (String line : output.getStdoutLines(true)) {
      if (line.startsWith(key) && line.length() >= (key.length() + 1)) {
        final String prettyName = line.substring(key.length() + 1);
        return StringUtil.nullize(StringUtil.unquoteString(prettyName));
      }
    }
  }
  catch (ExecutionException e) {
    LOG.warn(e);
  }
  return null;
}
 
Example #16
Source File: LaunchCommandsTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void failsForTestNameWithoutTestScript() {
  final BazelTestFields fields = new FakeBazelTestFields(
    BazelTestFields.forTestName("first test", "/workspace/foo/test/foo_test.dart", null),
    "scripts/daemon.sh",
    "scripts/doctor.sh",
    "scripts/launch.sh",
    null,
    null,
    null
  );
  boolean didThrow = false;
  try {
    final GeneralCommandLine launchCommand = fields.getLaunchCommand(projectFixture.getProject(), RunMode.RUN);
  }
  catch (ExecutionException e) {
    didThrow = true;
  }
  assertTrue("This test method expected to throw an exception, but did not.", didThrow);
}
 
Example #17
Source File: WeaveDebuggerRunner.java    From mule-intellij-plugins with Apache License 2.0 6 votes vote down vote up
@Nullable
protected RunContentDescriptor attachVirtualMachine(final RunProfileState state, final @NotNull ExecutionEnvironment env)
        throws ExecutionException
{

    return XDebuggerManager.getInstance(env.getProject()).startSession(env, new XDebugProcessStarter()
    {
        @NotNull
        public XDebugProcess start(@NotNull XDebugSession session) throws ExecutionException
        {
            WeaveRunnerCommandLine weaveRunnerCommandLine = (WeaveRunnerCommandLine) state;
            final String weaveFile = weaveRunnerCommandLine.getModel().getWeaveFile();
            final Project project = weaveRunnerCommandLine.getEnvironment().getProject();
            final VirtualFile projectFile = project.getBaseDir();
            final String path = project.getBasePath();
            final String relativePath = weaveFile.substring(path.length());
            final VirtualFile fileByRelativePath = projectFile.findFileByRelativePath(relativePath);
            final DebuggerClient localhost = new DebuggerClient(new WeaveDebuggerClientListener(session, fileByRelativePath), new TcpClientDebuggerProtocol("localhost", 6565));
            final ExecutionResult result = state.execute(env.getExecutor(), WeaveDebuggerRunner.this);
            new DebuggerConnector(localhost).start();
            return new WeaveDebugProcess(session, localhost, result);
        }
    }).getRunContentDescriptor();

}
 
Example #18
Source File: BlazeIntellijPluginDeployer.java    From intellij with Apache License 2.0 5 votes vote down vote up
/**
 * Returns information about which plugins will be deployed, and asynchronously copies the
 * corresponding files to the sandbox.
 */
DeployedPluginInfo deployNonBlocking() throws ExecutionException {
  if (deployInfoFiles.isEmpty()) {
    throw new ExecutionException("No plugin files found. Did the build fail?");
  }
  List<IntellijPluginDeployInfo> deployInfoList = Lists.newArrayList();
  for (File deployInfoFile : deployInfoFiles) {
    deployInfoList.addAll(readDeployInfoFromFile(deployInfoFile));
  }
  ImmutableMap<File, File> filesToDeploy = getFilesToDeploy(executionRoot, deployInfoList);
  this.filesToDeploy.putAll(filesToDeploy);
  ImmutableSet<File> javaAgentJars =
      deployJavaAgents.getValue() ? listJavaAgentFiles(deployInfoList) : ImmutableSet.of();

  for (File file : filesToDeploy.keySet()) {
    if (!file.exists()) {
      throw new ExecutionException(
          String.format("Plugin file '%s' not found. Did the build fail?", file.getName()));
    }
  }
  // kick off file copying task asynchronously, so it doesn't block the EDT.
  fileCopyingTask =
      BlazeExecutor.getInstance()
          .submit(
              () -> {
                for (Map.Entry<File, File> entry : filesToDeploy.entrySet()) {
                  copyFileToSandbox(entry.getKey(), entry.getValue());
                }
                return null;
              });

  return new DeployedPluginInfo(readPluginIds(filesToDeploy.keySet()), javaAgentJars);
}
 
Example #19
Source File: FastpassUtils.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
public static CompletableFuture<Void> amendAll(@NotNull PantsBspData importData, Collection<String> newTargets, Project project)
  throws IOException, ExecutionException {
  List<String> amendPart = Arrays.asList(
    "amend",  "--no-bloop-exit", "--intellij", "--intellij-launcher", "echo",
    importData.getBspPath().getFileName().toString(),
    "--new-targets", String.join(",", newTargets)
  );
  GeneralCommandLine command = makeFastpassCommand(project, amendPart);
  Process process = fastpassProcess(command, importData.getBspPath().getParent(), Paths.get(importData.getPantsRoot().getPath()));
  return onExit(process).thenAccept(__ -> {});
}
 
Example #20
Source File: BlazeAndroidBinaryNormalBuildRunContextBase.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public LaunchTask getApplicationLaunchTask(
    LaunchOptions launchOptions,
    @Nullable Integer userId,
    @NotNull String contributorsAmStartOptions,
    AndroidDebugger androidDebugger,
    AndroidDebuggerState androidDebuggerState,
    ProcessHandlerLaunchStatus processHandlerLaunchStatus)
    throws ExecutionException {
  String extraFlags = UserIdHelper.getFlagsFromUserId(userId);
  if (!contributorsAmStartOptions.isEmpty()) {
    extraFlags += (extraFlags.isEmpty() ? "" : " ") + contributorsAmStartOptions;
  }

  final StartActivityFlagsProvider startActivityFlagsProvider =
      new DefaultStartActivityFlagsProvider(
          androidDebugger, androidDebuggerState, project, launchOptions.isDebug(), extraFlags);

  BlazeAndroidDeployInfo deployInfo;
  try {
    deployInfo = buildStep.getDeployInfo();
  } catch (ApkProvisionException e) {
    throw new ExecutionException(e);
  }

  return BlazeAndroidBinaryApplicationLaunchTaskProvider.getApplicationLaunchTask(
      applicationIdProvider,
      deployInfo.getMergedManifest(),
      configState,
      startActivityFlagsProvider,
      processHandlerLaunchStatus);
}
 
Example #21
Source File: BlazeIntellijPluginDeployer.java    From intellij with Apache License 2.0 5 votes vote down vote up
private static void copyFileToSandbox(File src, File dest) throws ExecutionException {
  try {
    dest.getParentFile().mkdirs();
    Files.copy(src.toPath(), dest.toPath(), StandardCopyOption.REPLACE_EXISTING);
    dest.deleteOnExit();
  } catch (IOException e) {
    throw new ExecutionException("Error copying plugin file to sandbox", e);
  }
}
 
Example #22
Source File: DeployToServerState.java    From consulo with Apache License 2.0 5 votes vote down vote up
@javax.annotation.Nullable
@Override
public ExecutionResult execute(Executor executor, @Nonnull ProgramRunner runner) throws ExecutionException {
  final ServerConnection connection = ServerConnectionManager.getInstance().getOrCreateConnection(myServer);
  final Project project = myEnvironment.getProject();
  RemoteServersView.getInstance(project).showServerConnection(connection);

  final DebugConnector<?,?> debugConnector;
  if (DefaultDebugExecutor.getDebugExecutorInstance().equals(executor)) {
    debugConnector = myServer.getType().createDebugConnector();
  }
  else {
    debugConnector = null;
  }
  connection.computeDeployments(new Runnable() {
    @Override
    public void run() {
      connection.deploy(new DeploymentTaskImpl(mySource, myConfiguration, project, debugConnector, myEnvironment),
                        new ParameterizedRunnable<String>() {
                          @Override
                          public void run(String s) {
                            RemoteServersView.getInstance(project).showDeployment(connection, s);
                          }
                        });
    }
  });
  return null;
}
 
Example #23
Source File: OpenInAndroidStudioAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void openFileInStudio(@NotNull VirtualFile projectFile, @NotNull String androidStudioPath, @Nullable String sourceFile) {
  try {
    final GeneralCommandLine cmd;
    if (SystemInfo.isMac) {
      cmd = new GeneralCommandLine().withExePath("open").withParameters("-a", androidStudioPath, "--args", projectFile.getPath());
      if (sourceFile != null) {
        cmd.addParameter(sourceFile);
      }
    }
    else {
      // TODO Open editor on sourceFile for Linux, Windows
      if (SystemInfo.isWindows) {
        androidStudioPath += "\\bin\\studio.bat";
      }
      cmd = new GeneralCommandLine().withExePath(androidStudioPath).withParameters(projectFile.getPath());
    }
    final OSProcessHandler handler = new OSProcessHandler(cmd);
    handler.addProcessListener(new ProcessAdapter() {
      @Override
      public void processTerminated(@NotNull final ProcessEvent event) {
        if (event.getExitCode() != 0) {
          FlutterMessages.showError("Error Opening", projectFile.getPath());
        }
      }
    });
    handler.startNotify();
  }
  catch (ExecutionException ex) {
    FlutterMessages.showError(
      "Error Opening",
      "Exception: " + ex.getMessage());
  }
}
 
Example #24
Source File: BlazeAndroidBinaryMobileInstallRunContextBase.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public LaunchTask getApplicationLaunchTask(
    LaunchOptions launchOptions,
    @Nullable Integer userId,
    String contributorsAmStartOptions,
    AndroidDebugger androidDebugger,
    AndroidDebuggerState androidDebuggerState,
    ProcessHandlerLaunchStatus processHandlerLaunchStatus)
    throws ExecutionException {

  String extraFlags = UserIdHelper.getFlagsFromUserId(userId);
  if (!contributorsAmStartOptions.isEmpty()) {
    extraFlags += (extraFlags.isEmpty() ? "" : " ") + contributorsAmStartOptions;
  }

  final StartActivityFlagsProvider startActivityFlagsProvider =
      new DefaultStartActivityFlagsProvider(
          androidDebugger, androidDebuggerState, project, launchOptions.isDebug(), extraFlags);
  BlazeAndroidDeployInfo deployInfo;
  try {
    deployInfo = buildStep.getDeployInfo();
  } catch (ApkProvisionException e) {
    throw new ExecutionException(e);
  }

  return BlazeAndroidBinaryApplicationLaunchTaskProvider.getApplicationLaunchTask(
      applicationIdProvider,
      deployInfo.getMergedManifest(),
      configState,
      startActivityFlagsProvider,
      processHandlerLaunchStatus);
}
 
Example #25
Source File: HaxeTestsRunner.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
@Override
protected RunContentDescriptor doExecute(@NotNull final Project project,
                                         @NotNull RunProfileState state,
                                         final RunContentDescriptor descriptor,
                                         @NotNull final ExecutionEnvironment environment) throws ExecutionException {

  final HaxeTestsConfiguration profile = (HaxeTestsConfiguration)environment.getRunProfile();
  final Module module = profile.getConfigurationModule().getModule();

  ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
  VirtualFile[] roots = rootManager.getContentRoots();

  return super.doExecute(project, new CommandLineState(environment) {
    @NotNull
    @Override
    protected ProcessHandler startProcess() throws ExecutionException {
      //actually only neko target is supported for tests
      HaxeTarget currentTarget = HaxeTarget.NEKO;
      final GeneralCommandLine commandLine = new GeneralCommandLine();
      commandLine.setWorkDirectory(PathUtil.getParentPath(module.getModuleFilePath()));
      commandLine.setExePath(currentTarget.getFlag());
      final HaxeModuleSettings settings = HaxeModuleSettings.getInstance(module);
      String folder = settings.getOutputFolder() != null ? (settings.getOutputFolder() + "/release/") : "";
      commandLine.addParameter(getFileNameWithCurrentExtension(currentTarget, folder + settings.getOutputFileName()));

      final TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory.getInstance().createBuilder(module.getProject());
      consoleBuilder.addFilter(new ErrorFilter(module));
      setConsoleBuilder(consoleBuilder);

      return new OSProcessHandler(commandLine.createProcess(), commandLine.getCommandLineString());
    }

    private String getFileNameWithCurrentExtension(HaxeTarget haxeTarget, String fileName) {
      if (haxeTarget != null) {
        return haxeTarget.getTargetFileNameWithExtension(FileUtil.getNameWithoutExtension(fileName));
      }
      return fileName;
    }
  }, descriptor, environment);
}
 
Example #26
Source File: PantsCompileOptionsExecutor.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
private ProcessOutput getProcessOutput(
  @NotNull GeneralCommandLine command
) throws ExecutionException {
  final Process process = command.createProcess();
  myProcesses.add(process);
  final ProcessOutput processOutput = PantsUtil.getCmdOutput(process, command.getCommandLineString(), null);
  myProcesses.remove(process);
  return processOutput;
}
 
Example #27
Source File: AttachState.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected RunContentDescriptor launch(@NotNull ExecutionEnvironment env) throws ExecutionException {
  Project project = getEnvironment().getProject();
  FlutterDevice device = DeviceService.getInstance(project).getSelectedDevice();
  if (device == null) {
    showNoDeviceConnectedMessage(project);
    return null;
  }
  FlutterApp app = getCreateAppCallback().createApp(device);
  // Cache for use in console configuration, and for updating registered extensionRPCs.
  FlutterApp.addToEnvironment(env, app);
  ExecutionResult result = setUpConsoleAndActions(app);
  return createDebugSession(env, app, result).getRunContentDescriptor();
}
 
Example #28
Source File: BlazeAndroidBinaryNormalBuildRunContextBase.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public ImmutableList<LaunchTask> getDeployTasks(IDevice device, LaunchOptions launchOptions)
    throws ExecutionException {
  ImmutableMap<String, List<File>> filesToInstall =
      getFilesToInstall(device, launchOptions, apkProvider);
  return ImmutableList.of(getDeployTask(launchOptions, filesToInstall));
}
 
Example #29
Source File: BlazeGoRunConfigurationRunner.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public RunProfileState getRunProfileState(Executor executor, ExecutionEnvironment env)
    throws ExecutionException {
  BlazeCommandRunConfiguration configuration =
      BlazeCommandRunConfigurationRunner.getConfiguration(env);
  if (!BlazeCommandRunConfigurationRunner.isDebugging(env)
      || BlazeCommandName.BUILD.equals(BlazeCommandRunConfigurationRunner.getBlazeCommand(env))) {
    return new BlazeCommandRunProfileState(env);
  }
  env.putCopyableUserData(EXECUTABLE_KEY, new AtomicReference<>());
  return new BlazeGoDummyDebugProfileState(configuration);
}
 
Example #30
Source File: BlazeAndroidDeviceSelector.java    From intellij with Apache License 2.0 5 votes vote down vote up
DeviceSession getDevice(
Project project,
AndroidFacet facet,
BlazeAndroidRunConfigurationDeployTargetManager deployTargetManager,
Executor executor,
ExecutionEnvironment env,
AndroidSessionInfo info,
boolean debug,
int runConfigId)
throws ExecutionException;