Programmatically adding a BeforeRunTask to existing RunConfigurations

Hello,

I am trying to add a custom BeforeRunTask to existing RunConfigurations when I project is opened. So I added this bit of code to the projectOpened method of my ProjectComponent.

for (RunConfiguration runConfiguration : runManager.getAllConfigurationsList()) {
            List<BeforeRunTask> beforeRunTasks = runManager.getBeforeRunTasks(runConfiguration);
            beforeRunTasks.add(new MyBeforeRunTask(providerID));
            runManager.setBeforeRunTasks(runConfiguration, beforeRunTasks, true);
}

I also extended the stepsBeforeRunProvider extension point with this extension:

<stepsBeforeRunProvider implementation="my.package.MyBeforeRunTaskProvider"></stepsBeforeRunProvider>


However, when I run my plugin, the steps are not added to the existing configs. I can go and manually add them, they appear in the dropdown list. And the provider gets called just fine after I add them manually.

I believe I am missing a step here. Any ideas?

Thanks,
-Caius

1 comment
Comment actions Permalink

In case anyone else finds this post looking for answers, you also need to enable the tasks before adding them to the list:

List<BeforeRunTask> beforeRunTasks = runManager.getBeforeRunTasks(runConfiguration);
MyBeforeRunTask task = new MyBeforeRunTask(providerID);
task.setEnabled(true); // <---- important!
beforeRunTasks.add(task);
runManager.setBeforeRunTasks(runConfiguration, beforeRunTasks, true);

 

0

Please sign in to leave a comment.