plugin to Execute Multiple Run Configurations

Hi,

I'm trying to write a plugin to implement this feature request: http://youtrack.jetbrains.com/issue/IDEA-64839

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?

Thanks!
0
4 comments

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().

0

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();
MacroManager.getInstance().cacheMacrosPreview(event.getDataContext());
RunnerAndConfigurationSettings configuration = null;
configuration = getConfiguration(project);
PluginState stateService = ServiceManager.getService(project, PluginState.class);
String vmParams = stateService.getVmParams();
String executionParams = vmParams + " -Druntime.run=runMe;
if (configuration != null) {
configurationsetVMParameters(executionParams);
configuration.setAllowRunningInParallel(true);
}
if (configuration != null) {
var conn = project.getMessageBus().connect();
conn.subscribe(ExecutionManager.EXECUTION_TOPIC, new ExecutionListener() {
@Override
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);
ExecutionManager.getInstance(project).restartRunProfile(builder.activeTarget().dataContext(event.getDataContext()).build());
}

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

0

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

0

Please sign in to leave a comment.