Programmatically Load Run Configurations From Disk

Hi all,

 

I have a requirement to create a plugin to load arbitrary run configurations from disk... The configurations are saved into Subversion source code control as individual XML files but I'm struggling to find out how one would read this into an existing project/module structure...

I've taken a look at RunConfiguration (and base classes such as ApplicationConfiguration) to try and understand how readExternal() might work, but I'm a bit stumped...

Any pointers? Basically I want to iterate over a directory and load each in turn...

Regards,

Si

7 comments

> to load arbitrary run configurations from disk

What do you mean "arbitrary"? Not mapped to some IDEA run configuration type?

0

Hiya, thanks for taking the time, no, I'm sorry, these are all Java Application run configurations, I just mean 'arbitrary' in as much as the user will select a directory from a UI dialog from where to load the XML configuration files...

The file look like:

<component name="ProjectRunConfigurationManager">
<configuration default="false" name="BorrowsCLI - PollForResponse (by attribs)" type="Application" factoryName="Application" folderName="Borrows">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" value="wigwam.borrows.server.cli.BorrowsCLIMain" />
<option name="VM_PARAMETERS" value="-Xmx128m -Dlogback.configurationFile=src/test/resources/intellij.logback.xml" />
<option name="PROGRAM_PARAMETERS" value="--root-path \\wigwam001\Rhapsody_Equities\vector_ems_sm --mission MatrixSM --instance Primary --application Borrows --component borrows-cli PollForResponse -bd 2016-02-25 -rt INDICATIVE -r AUSTRALIA -b &quot;Fishy&quot;" />
<option name="WORKING_DIRECTORY" value="file://$MODULE_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" value="" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="BorrowsCLI" />
<envs />
<method />
</configuration>
</component>

 

 

0

As this forum doesn't support markdown, I have answered using GitHub gist — https://gist.github.com/develar/70e874eaa8d27958aeef2337c917e1b2

0

Hi Vladimir,

 

Many many thanks for the help, I have certainly got further, although I have had to do something like:

RunnerAndConfigurationSettingsImpl settings = new RunnerAndConfigurationSettingsImpl(manager, new ApplicationConfiguration("Borrows", project, new ApplicationConfigurationType()), false);
Element data = JDOMUtil.load(new File("C:/Development/subversion/trunk/java/CoreTradingPlatform/data/runConfigurations/BorrowsCLI___PollForResponse__by_attribs_.xml"));
settings.readExternal(data);
manager.addConfiguration(settings, false , new ArrayList<BeforeRunTask>(), true);

The configuration DOES get created, but all fields are blank and module is undefined...

Will keep digging, many thanks for the help,

 

Simon

0

Please do not use ctor `

RunnerAndConfigurationSettingsImpl(RunManagerImpl manager, @NotNull RunConfiguration configuration, boolean isTemplate)

`

please use `

RunnerAndConfigurationSettingsImpl(RunManagerImpl manager)` as in my example.
0

Hi Validimir,

 

Yes, I did use your original code, but it gives me:

java.lang.NullPointerException
at com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl.getUniqueID(RunnerAndConfigurationSettingsImpl.java:293)
at com.intellij.execution.impl.RunManagerImpl.addConfiguration(RunManagerImpl.java:341)

As the internal configuration object 'myConfiguration' is null...

Cheers,

Si

 

0

OK Vladimir, nailed it...

My XML configurations are wrapped in a top level element, if I use this:

settings.readExternal(data.getChildren().get(0));


then the 'inner' configuration element is used and all my configs get loaded!

Many many thanks for all the help,

 

Si

0

Please sign in to leave a comment.