VMRunnerConfiguration vmConfig = new VMRunnerConfiguration(Constants.GWT_COMPILER_CLASS, (String[]) classpath.toArray(new String[classpath.size()]));
vmConfig.setWorkingDirectory(project.getLocation().toOSString());
List compilerArgs = Helper.getCompilerArgs(launchConfig);
vmConfig.setProgramArguments((String[]) compilerArgs.toArray(new String[compilerArgs.size()]));
final ILaunch compiler = new Launch(null, ILaunchManager.RUN_MODE, null);
DebugPlugin.getDefault().addDebugEventListener(new IDebugEventSetListener() {
public void handleDebugEvents(DebugEvent[] events) {
for(int i = 0;i<events.length;i++) {
DebugEvent event = events[i];
Object source = event.getSource();
if (source instanceof IProcess && event.getKind() == DebugEvent.TERMINATE) {
ILaunch launch = ((IProcess) source).getLaunch();
if (compiler.equals(launch)) {
DebugPlugin.getDefault().removeDebugEventListener(this);
// wakeup the publisher
synchronized (GwtProject.this) {
GwtProject.this.notify();
}
}
}
}
}
});
vmRunner.run(vmConfig, compiler, null);
try {
synchronized (this) {
int i = 0;
while(!compiler.isTerminated() && i < 8) {
wait(5000);
i++;
}
// TODO: we throw an exception on timeout?
}