I am writing an Eclipse plugin contributing a new launch configuration type. It works perfectly expected that when the execution of a launch configuration for this new type is completed, the launch configuration button tooltip still indicates that my configuration is running.
This causes problem when I want to launch several of such configurations using launch groups, the second configuration waits indefinitely for the first one to complete (I am using the wait until termination option from the launch group). So I guess I am missing something to tell the platform that the execution of the launch config is completed.
If I remember correctly, you need to start a new system Process
when your launch configuration is launched (ILaunchConfigurationDelegate#launch
) and then create a RuntimeProcess
for this Process
. The RuntimeProcess
will then generate the necessary DebugEvents
and notify the corresponding ILaunch
when it was terminated.
You will usually create the RuntimeProcess
by calling DebugPlugin#newProcess(ILaunch, Process, String)
but it is also possible to instantiate it directly (e.g. if you want to extend the class RuntimeProcess
).
By looking at sample launch configurations (mainly the one provided by the Ant plugin), there is an org.eclipse.debug.core.model.ITerminate
interface that is implemented in the process/debug targets that execute in the launch.
A org.eclipse.debug.core.IDebugEventSetListener
is registered to handle terminate events which are triggered by calling the following statement:
DebugPlugin.getDefault().fireDebugEventSet(
new DebugEvent[] {new DebugEvent(this, DebugEvent.TERMINATE)});
Sample code from the AntLaunchDelegate
class:
final boolean[] terminated = new boolean[1];
terminated[0] = launch.isTerminated();
IDebugEventSetListener listener = new IDebugEventSetListener() {
public void handleDebugEvents(DebugEvent[] events) {
for (int i = 0; i < events.length; i++) {
DebugEvent event = events[i];
for (int j = 0, numProcesses = processes.length; j < numProcesses; j++) {
if (event.getSource() == processes[j]
&& event.getKind() == DebugEvent.TERMINATE) {
terminated[0] = true;
break;
}
}
}
}
};
DebugPlugin.getDefault().addDebugEventListener(listener);
monitor
.subTask(AntLaunchConfigurationMessages.AntLaunchDelegate_28);
while (!monitor.isCanceled() && !terminated[0]) {
try {
Thread.sleep(50);
} catch (InterruptedException e) {
}
}
DebugPlugin.getDefault().removeDebugEventListener(listener);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With