Start 'Run' programmitcally

Hi,

 

I might just not be able to find what I am looking for in the lack of the right vocabulary. So be gentle, I am new to IntelliJ Development :)

I am looking for a possibility to start the 'Run' Action (Task???) programmatically. I got the file hook already, but I can't seem to find the right command to run an already existing action.

 

Cheers

Donut

1 comment
Comment actions Permalink

First of all you need DataContext, if you have some custom action it would come automatically, otherwise you should obtain one, for example DataManager.getInstance().getDataContext(JComponent) or just prepare your own instance.

Then you call

ConfigurationContext context = ConfigurationContext.getFromContext(dataContext);
RunnerAndConfigurationSettings settings = context.findExisting();
if (settings != null) {
   ExecutionUtil.runConfiguration(settings, DefaultRunExecutor.getRunExecutorInstance());
}

and it runs.

0

Please sign in to leave a comment.