plugin to Execute Multiple Run Configurations


I'm trying to write a plugin to implement this feature request:

Here's the code I've got so far.  Its based on the GarbageCollectionAction sample.

    private static List<String> runConfigs = Arrays.asList("RunConfigName1", "RunConfigName2", "RunConfigName3");

    public void actionPerformed(AnActionEvent event) {

        Project project = event.getData( PlatformDataKeys.PROJECT );
        RunManagerImpl runManager = (RunManagerImpl) RunManager.getInstance(project);

        RunConfiguration[] allConfigurations = runManager.getAllConfigurations();
        for (RunConfiguration config : allConfigurations) {
            if( runConfigs.contains(config.getName()) ) {
                Executor runExecutorInstance = DefaultRunExecutor.getRunExecutorInstance();
                RunnerAndConfigurationSettings settings = runManager.getSettings(config);
                ProgramRunnerUtil.executeConfiguration(project, settings, runExecutorInstance);


When I click the menu item this almost works in that RunConfigName1 starts correctly, I get the log view and everything, but the subsquent configurations don't start.  If I set a break point I can see that ProgramRunnerUtil.executeConfiguration is getting called for each of the run configurations I'm interested in, but something is preventing them from starting.

Any suggestions on how to debug this?


Before you can start another configuration, you must wait for the first run configuration to complete startup. To receive notifications about the startup completion, you can subscribe to the ExecutionManager.EXECUTION_TOPIC. You can find an example of doing that in ExecutorRegistryImpl.initComponent().


I have a similar question.  I was able to subscribe to the event but how can I then run a new instance?

Here is my code

var project = event.getData(PlatformDataKeys.PROJECT);

VirtualFile @NotNull [] files = FileChooser.chooseFiles(FileChooserDescriptorFactory.createMultipleFilesNoJarsDescriptor(), project, null);
for (VirtualFile file : files) {
var filePath = file.getCanonicalPath();
RunnerAndConfigurationSettings configuration = null;
configuration = getConfiguration(project);
PluginState stateService = ServiceManager.getService(project, PluginState.class);
String vmParams = stateService.getVmParams();
String executionParams = vmParams + ";
if (configuration != null) {
if (configuration != null) {
var conn = project.getMessageBus().connect();
conn.subscribe(ExecutionManager.EXECUTION_TOPIC, new ExecutionListener() {
public void processTerminated(@NotNull String executorId, @NotNull ExecutionEnvironment env, @NotNull ProcessHandler handler, int exitCode) {
ExecutionListener.super.processTerminated(executorId, env, handler, exitCode);
var builder = ExecutionEnvironmentBuilder.createOrNull(new DefaultRunExecutor(), configuration);

I should mention that this code is within actionPerformed, which maybe the issue.  Does it have to be above this?


I figured out what i need to do.  There are a number of issues with my approach.  Once I have it figured out, I will post here


Please sign in to leave a comment.