GWT SuperDevMode: Spawn codeserver and Daemon in same process

Simplify SDM experience by embedding codeserver and daemon in one
process: no multiple launch configurations must be started and
the output must not be captured in different IDE console windows.

Unfortunately, as is Codeserver implementation is based on outdated
Jetty. Replace WebServer.java from GWT project (same license like
Gerrit itself, preserving the license header) and adjust it to run
against Jetty 9 that is used by Gerrit.

This also removes the need to fetch outdated Jetty version that we
have just wiped out from gwt-dev.jar during download from Central.

Change-Id: I616a53eb080d49a2bdf7a2211067b821af9f85d7
This commit is contained in:
David Ostrovsky
2014-08-18 08:46:13 +02:00
parent 430d50527a
commit 9adf60e96f
9 changed files with 623 additions and 36 deletions

View File

@@ -0,0 +1,80 @@
// Copyright (C) 2014 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.gwtdebug;
import com.google.gerrit.pgm.Daemon;
import com.google.gwt.dev.codeserver.CodeServer;
import com.google.gwt.dev.codeserver.Options;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
class GerritSDMLauncher {
private static final Logger log = LoggerFactory.getLogger(GerritSDMLauncher.class);
public static void main(String[] argv) throws Exception {
GerritSDMLauncher launcher = new GerritSDMLauncher();
launcher.mainImpl(argv);
}
private int mainImpl(String[] argv) {
List<String> sdmLauncherOptions = new ArrayList<>();
List<String> daemonLauncherOptions = new ArrayList<>();
// Separator between Daemon and Codeserver parameters is "--"
boolean daemonArgumentSeparator = false;
int i = 0;
for (; i < argv.length; i++) {
if (!argv[i].equals("--")) {
sdmLauncherOptions.add(argv[i]);
} else {
daemonArgumentSeparator = true;
break;
}
}
if (daemonArgumentSeparator) {
++i;
for (; i < argv.length; i++) {
daemonLauncherOptions.add(argv[i]);
}
}
Options options = new Options();
if (!options.parseArgs(sdmLauncherOptions.toArray(
new String[sdmLauncherOptions.size()]))) {
log.error("Failed to parse codeserver arguments");
return 1;
}
CodeServer.main(options);
try {
int r = new Daemon().main(daemonLauncherOptions.toArray(
new String[daemonLauncherOptions.size()]));
if (r != 0) {
log.error("Daemon exited with return code: " + r);
return 1;
}
} catch (Exception e) {
log.error("Cannot start daemon", e);
return 1;
}
return 0;
}
}