How to create and execute a CompoundRunConfiguration programmatically Follow
I am trying to create multiple MavenRunConfigurations programmatically and execute them.
Creating and executing one RunnerAndConfigurationSettings works fine with this lines of code:
RunnerAndConfigurationSettings mavenRunnerAndConfigurationSettings = MavenRunConfigurationType.createRunnerAndConfigurationSettings(null,new MavenRunnerSettings(),createMavenRunnerParameters(...), project);
ProgramRunnerUtil.executeConfiguration(mavenRunnerAndConfigurationSettings , DefaultRunExecutor.getRunExecutorInstance());
But this only works for one RunnerAndConfigurationSettings. If I try it with 2 RunnerAndConfigurationSettings only the first is executed.
Then I saw the CompoundRunConfiguration which do what I want. But I can´t figure out how to create and execute a CompoundRunConfiguration.
I tried it with the following code but no success. After calling the action in idea nothing happend. The code is executed because I see the log, but the CompoundRunConfiguration is not executed.
CompoundRunConfigurationType type = ConfigurationTypeUtil.findConfigurationType(CompoundRunConfigurationType.class);
RunnerAndConfigurationSettings settings = RunManager.getInstance(project).createConfiguration(name, type);
CompoundRunConfiguration runConfiguration = (CompoundRunConfiguration)settings.getConfiguration();
Map<RunConfiguration, ExecutionTarget> map = new HashMap<>();
Executor runExecutorInstance = DefaultRunExecutor.getRunExecutorInstance();
ExecutionEnvironment env = ExecutionEnvironmentBuilder.create(runExecutorInstance, runnerAndConfigurationSettings).contentToReuse(null).dataContext(null).activeTarget().build();
ProgramRunnerUtil.executeConfiguration(env, true, true);
Any ideas how I can execute programmatically created MavenRunConfigurations (more than one)?
Please sign in to leave a comment.
I have now found a solution. Use "executeConfigurationAsync" with Callback-Interface and start next RunConfiguration after the current terminated successfull.