Adding launchers to the platform

Your plug-in can add launch configuration types to the platform using the org.eclipse.debug.core.launchConfigurationTypes extension point.  This extension point allows you to declare a configuration type using a unique id.  You must provide a corresponding implementation of ILaunchConfigurationDelegate. The delegate is responsible for launching its launch configuration in a specified mode. Optionally, you can implement ILaunchConfigurationDelegate2, which enhances the delegate interface to allow your delegate to abort a launch, build relevant projects in the workspace before a launch, and control the creation of the launch object that is used in a launch.

In addition to defining the delegate, you can specify which launch modes are supported by your delegate, and a name that should be used when showing launchers of this type to the user.

The following markup shows how the Java tools declare a Java launch configuration for launching local Java programs:

<extension point = "org.eclipse.debug.core.launchConfigurationTypes">
   <launchConfigurationType
   	   id="org.eclipse.jdt.launching.localJavaApplication"
	   name="%localJavaApplication"
	   delegate="org.eclipse.jdt.internal.launching.JavaLocalApplicationLaunchConfigurationDelegate"
	   modes= "run, debug"
	   sourceLocatorId="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"
       sourcePathComputerId="org.eclipse.jdt.launching.sourceLookup.javaSourcePathComputer">
   </launchConfigurationType>
</extension>

This extension defines a launch configuration delegate that can be used to run or debug programs that are launched using the local Java launch configuration.

Defining new launch modes

We mentioned previously that the platform defines launch modes for running, debugging, or profiling a program. These modes are defined using the org.eclipse.debug.core.launchModes extension point. This extension point allows you to declare a launch mode by defining its string mode name and the label that should be shown to the user to describe the mode. The following markup shows the definition of the platform's three standard launch modes:

<extension point="org.eclipse.debug.core.launchModes">
	<launchMode
		label="%run"
		mode="run">
	</launchMode>
	<launchMode
		label="%debug"
		mode="debug">
	</launchMode>
	<launchMode
		label="%profile"
		mode="profile">
	</launchMode>
</extension>

Note that the mode is not associated with any particular launch configuration type. As shown earlier, that association occurs when a launch delegate is specified for a configuration type.

Defining launch delegates

Since launch modes can be specified independently of launch configuration types, it's possible that new modes are defined that are not implemented by the original delegate for a launch configuration. In this case, a plug-in may define a launch delegate that implements a particular mode for a particular launch configuration type. This can be done using the org.eclipse.debug.core.launchDelegates extension point. This extension point allows you to define a launch delegate that implements the specified modes for a given configuration type. The following markup shows how you could define a delegate for profiling a local Java application:

<extension point="org.eclipse.debug.core.launchDelegates">
  <launchDelegate
   id="com.example.MyJavaProfileDelegate"
   delegate="com.example.MyJavaProfileDelegate"
   type="org.eclipse.jdt.launching.localJavaApplication"
   modes="profile">
  </launchDelegate>
 </extension>

The specification of the delegate is similar to the way it is done when defining a launch configuration type, except that in this case the type of launch configuration is specified along with the supported modes. As seen previously, the delegate must implement ILaunchConfigurationDelegate, and can optionally implement ILaunchConfigurationDelegate2 for more control over the launch sequence.

Other references

We Have Lift-off: The Launching Framework in Eclipse provides a start to finish example for defining your own launch type.