intellij-sdk-code-samples/topics/tutorials/run_configurations_tutorial.md

3.8 KiB

Run Configurations Tutorial

Implementing a custom run configuration tutorial.

Product Help: Run/Debug Configuration

This step-by-step guide shows how to register and implement a simple run configuration. Run configurations are used to run internal and external processes from within IntelliJ Platform based products.

The full implementation is available in the code samples.

Pre-Requirements

Create an empty plugin project. See the section for details.

Implement a ConfigurationType

Implement ConfigurationType:

{src="run_configuration/src/main/java/org/jetbrains/sdk/runConfiguration/DemoRunConfigurationType.java" include-symbol="DemoRunConfigurationType"}

Register the ConfigurationType

Register implemented configuration type in com.intellij.configurationType extension point in the plugin.xml:

<extensions defaultExtensionNs="com.intellij">
  <configurationType
      implementation="org.jetbrains.sdk.runConfiguration.DemoRunConfigurationType"/>
</extensions>

Implement a ConfigurationFactory

Implement a new ConfigurationFactory through which custom run configurations will be created.

{src="run_configuration/src/main/java/org/jetbrains/sdk/runConfiguration/DemoConfigurationFactory.java" include-symbol="DemoConfigurationFactory"}

Implement corresponding configuration options class extending RunConfigurationOptions to store settings.

{src="run_configuration/src/main/java/org/jetbrains/sdk/runConfiguration/DemoRunConfigurationOptions.java" include-symbol="DemoRunConfigurationOptions"}

Implement a RunConfiguration

To make your changes visible from the UI, implement a new run configuration.

In most of the cases it is sufficient derive a custom run configuration class from the RunConfigurationBase. If implementing specific settings externalization rules and I/O behaviour is required, use RunConfiguration interface.

{style="note"}

{src="run_configuration/src/main/java/org/jetbrains/sdk/runConfiguration/DemoRunConfiguration.java" include-symbol="DemoRunConfiguration"}

Implement the SettingsEditor

{src="run_configuration/src/main/java/org/jetbrains/sdk/runConfiguration/DemoSettingsEditor.java" include-symbol="DemoSettingsEditor"}

Compile and Run the Plugin

  1. Execute the plugin.
  2. Go to Run | Edit Configurations..., click to Add button (+ icon), and select Demo.
  3. In the Script file field provide the path to an example script (e.g. displaying "Hello world" message).
  4. Click the Apply button and close the dialog.
  5. In the run toolbar select created configuration and click the run button.

The script should be executed and its result should be displayed in the console.