How to reuse existing run configurations?

I want to create run configuration that basically will do the following:

Preprocess smth (In my case depending on file that is in settings of my configuration generate cpp file and put it to the scope of run configuration I need to run)
Run temporary created or already existed run configuration.

I've tried like this:

     @Nullable      @Override      public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException {           AppCodeAppRunConfigurationType configurationType = AppCodeAppRunConfigurationType.getInstance();           List<RunConfiguration> configurations = RunManager.getInstance(getProject()).getConfigurationsList(configurationType);           RunConfiguration outputConfiguration = null;           for (RunConfiguration configuration : configurations) {                if(configuration.getName().equals("output")) {                     outputConfiguration = configuration;                }           }           if(outputConfiguration == null) {                throw new JHelperException("Output configuration not found");           }           return outputConfiguration.getState(executor, environment);      }


But I'm constantly getting "Error running MyConfigurationName: Cannot run on '' (show balloon)"

So what I want to achieve as a first step: when myconfiguration running run another configuration, so that I'll be able to run custom code befire that.

1 comment
Comment actions Permalink

Well I manage to do that but in a hackish way.

I've created the ProgramRunner. Its `execute` method doesn't call getState() of my RunConfiguration. Instead, it finds run configuration with specific name and calls

ProgramRunnerUtil.executeConfiguration(project, outputSettings, environment.getExecutor()); // for CLion and

ExecutionTarget target = ExecutionTargetManager.getInstance(project).getTargetsFor(outputSettings).get(0);
ProgramRunnerUtil.executeConfiguration( project, null, outputSettings, environment.getExecutor(), target, null, false); // for AppCode

0

Please sign in to leave a comment.