summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--gerrit-pgm/src/main/java/com/google/gerrit/pgm/http/jetty/JettyServer.java59
-rw-r--r--tools/pgm_daemon.launch2
3 files changed, 61 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index fdd9fa12a3..9f3c4e125a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
/.project
/.settings/org.maven.ide.eclipse.prefs
/GerritServer.properties
+/test_site
diff --git a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/http/jetty/JettyServer.java b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/http/jetty/JettyServer.java
index 0c8e02819a..bf07dda358 100644
--- a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/http/jetty/JettyServer.java
+++ b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/http/jetty/JettyServer.java
@@ -53,6 +53,7 @@ import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashSet;
@@ -322,7 +323,11 @@ public class JettyServer {
try {
baseResource = unpackWar();
} catch (FileNotFoundException err) {
+ if (err.getMessage() == GerritLauncher.NOT_ARCHIVED) {
+ baseResource = useDeveloperBuild();
+ } else {
throw err;
+ }
}
}
return baseResource;
@@ -396,4 +401,58 @@ public class JettyServer {
dir.deleteOnExit();
}
}
+
+ private Resource useDeveloperBuild() throws IOException {
+ // Find ourselves in the CLASSPATH. We should be a loose class file.
+ //
+ URL u = getClass().getResource(getClass().getSimpleName() + ".class");
+ if (u == null) {
+ throw new FileNotFoundException("Cannot find web application root");
+ }
+ if (!"file".equals(u.getProtocol())) {
+ throw new FileNotFoundException("Cannot find web root from " + u);
+ }
+
+ // Pop up to the top level classes folder that contains us.
+ //
+ File dir = new File(u.getPath());
+ String myName = getClass().getName();
+ for (;;) {
+ int dot = myName.lastIndexOf('.');
+ if (dot < 0) {
+ dir = dir.getParentFile();
+ break;
+ }
+ myName = myName.substring(0, dot);
+ dir = dir.getParentFile();
+ }
+
+ // We should be in a Maven style output, that is $jar/target/classes.
+ //
+ if (!dir.getName().equals("classes")) {
+ throw new FileNotFoundException("Cannot find web root from " + u);
+ }
+ dir = dir.getParentFile(); // pop classes
+ if (!dir.getName().equals("target")) {
+ throw new FileNotFoundException("Cannot find web root from " + u);
+ }
+ dir = dir.getParentFile(); // pop target
+ dir = dir.getParentFile(); // pop the module we are in
+
+ // Drop down into gerrit-gwtui to find the WAR assets we need.
+ //
+ dir = new File(new File(dir, "gerrit-gwtui"), "target");
+ final File[] entries = dir.listFiles();
+ if (entries == null) {
+ throw new FileNotFoundException("No " + dir);
+ }
+ for (File e : entries) {
+ if (e.isDirectory() /* must be a directory */
+ && e.getName().startsWith("gerrit-gwtui-")
+ && new File(e, "gerrit/gerrit.nocache.js").isFile()) {
+ return Resource.newResource(e.toURI());
+ }
+ }
+ throw new FileNotFoundException("No " + dir + "/gerrit-gwtui-*");
+ }
}
diff --git a/tools/pgm_daemon.launch b/tools/pgm_daemon.launch
index 9dca1f8b5a..7aeca89805 100644
--- a/tools/pgm_daemon.launch
+++ b/tools/pgm_daemon.launch
@@ -13,7 +13,7 @@
<booleanAttribute key="org.eclipse.jdt.debug.ui.CONSIDER_INHERITED_MAIN" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.maven.ide.eclipse.launchconfig.classpathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="Main"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="daemon&#10;--console-log&#10;--show-stack-trace"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="daemon&#10;--console-log&#10;--show-stack-trace&#10;-d ${resource_loc:/gerrit-parent}/test_site"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="gerrit-war"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.maven.ide.eclipse.launchconfig.sourcepathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx256M"/>