Class RunConfigurations

All Implemented Interfaces:
ContextProvider, PropertyChangeSource, Rebindable

public class RunConfigurations extends AnahataToolkit
A toolkit for discovering and launching IntelliJ run/debug/test configurations.

A beyond-parity capability with no NetBeans equivalent: it uses the platform RunManager/ProgramRunnerUtil to enumerate configured run configurations and execute them with the standard Run executor. Test configurations (JUnit/TestNG/etc.) run the same way; their results appear in the IDE's Run/Test tool window. Capturing structured test results programmatically is deferred (it requires attaching to the test process's event listener).

Author:
anahata
  • Field Details

    • TEST_SUMMARY_PATTERN

      private static final Pattern TEST_SUMMARY_PATTERN
      Regex patterns to detect test runner summary lines across Maven, Gradle, JUnit, and TestNG.
    • TEST_FAILURE_PATTERN

      private static final Pattern TEST_FAILURE_PATTERN
      Regex pattern to detect test failure and error details.
    • BUILD_STATUS_PATTERN

      private static final Pattern BUILD_STATUS_PATTERN
      Regex pattern to detect Maven/Gradle build status lines.
  • Constructor Details

    • RunConfigurations

      public RunConfigurations()
      Constructs the RunConfigurations toolkit (instantiated reflectively via its public no-arg constructor).
  • Method Details

    • listRunConfigurations

      public String listRunConfigurations()
      Lists every run configuration across all open projects.
      Returns:
      a Markdown listing of configuration names, types and owning project.
    • runConfiguration

      public String runConfiguration(String name, Integer timeoutSeconds) throws AgiToolException
      Launches a run configuration by name using the standard Run executor.

      The configuration is looked up across open projects. If a positive timeout is specified, this method subscribes to ExecutionManager.EXECUTION_TOPIC, captures console output, waits for process termination, and returns a structured summary including exit code, duration, and test/build outcomes. Otherwise, execution runs asynchronously.

      Parameters:
      name - the exact configuration name.
      timeoutSeconds - optional timeout in seconds to wait for execution to complete. 0 or null launches asynchronously without blocking.
      Returns:
      a structured summary of the execution or a launch confirmation.
      Throws:
      AgiToolException - if no configuration with that name exists or waiting is interrupted.
    • executeWithStructuredWait

      private String executeWithStructuredWait(com.intellij.openapi.project.Project project, com.intellij.execution.RunnerAndConfigurationSettings settings, int timeoutSeconds) throws AgiToolException
      Executes a configuration synchronously while capturing process output and waiting for termination.
      Parameters:
      project - the host project.
      settings - the configuration settings.
      timeoutSeconds - timeout duration in seconds.
      Returns:
      structured execution summary.
      Throws:
      AgiToolException - if execution wait fails.