Switch to GWT 1.6's new HostedMode debugging utility

The pain in the neck thing is, we have to use their new WAR style
output, which requires us to run "mvn war:inplace" before we can
start debugging, or if any dependencies change, but we also need
to clean that out.

All RPC handles also moved inside of the module directory, which
makes it easier to debug in the hosted mode browser but breaks any
existing browser client, even though the JSON payloads have not
changed in format.

Bug: GERRIT-75
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce 2009-05-13 07:59:04 -07:00
parent fa0c7537af
commit 8d2f184389
24 changed files with 122 additions and 109 deletions

4
.gitignore vendored
View File

@ -6,6 +6,6 @@
/src/main/java/GerritServer.properties /src/main/java/GerritServer.properties
/src/main/java/com/google/gerrit/client/GerritVersion.properties /src/main/java/com/google/gerrit/client/GerritVersion.properties
/src/main/java/com/google/gerrit/client/GerritVersion_*.properties /src/main/java/com/google/gerrit/client/GerritVersion_*.properties
/gwt_www /src/main/webapp/gerrit
/tomcat /src/main/webapp/WEB-INF/lib
/hs_err_pid*.log /hs_err_pid*.log

View File

@ -23,7 +23,7 @@ Create a user library called `GWT_16`:
* Java > Build Path > User Libraries * Java > Build Path > User Libraries
* New * New
* Name: `GWT` * Name: `GWT_16`
* Add JARs... * Add JARs...
* Select `gwt-user.jar` from the $(GWT_SDK) directory. * Select `gwt-user.jar` from the $(GWT_SDK) directory.
@ -78,6 +78,27 @@ instructions in link:dev-readme.html[Developer Setup].
* Copy `GerritServer.properties_example` to `GerritServer.properties` * Copy `GerritServer.properties_example` to `GerritServer.properties`
* Configure your database for debugging in hosted mode. * Configure your database for debugging in hosted mode.
Bootstrap Compile
-----------------
From the command line we have to bootstrap the environment:
----
./to_hosted.sh
----
Production Compile
------------------
*Always* use
----
mvn clean package
----
to create a production build. The `./to_hosted.sh` used above
to setup the development environment for Eclipse hosted mode also
creates a state that produces a corrupt production build.
Launch Gerrit Launch Gerrit
------------- -------------
@ -88,19 +109,6 @@ Under Java Application find `gerrit_debug` (not Mac OS X)
or `gerrit_macos` (Mac OS X only) to start the GWT hosted or `gerrit_macos` (Mac OS X only) to start the GWT hosted
mode browser and debug through Eclipse. mode browser and debug through Eclipse.
SSH Daemon
~~~~~~~~~~
To get the SSH daemon started when running in hosted mode, you need
to manually hit the `ssh_info` URL to force the servlet initialize
and bind the daemon on port 29418 (or whatever you have it configured
to in `system_config`).
----
curl http://localhost:8888/com.google.gerrit.Gerrit/ssh_info
----
Final Setup Final Setup
----------- -----------

View File

@ -92,7 +92,7 @@ Building
From the command line: From the command line:
==== ====
mvn package mvn clean package
==== ====
Output WAR will be placed in: Output WAR will be placed in:
@ -110,6 +110,18 @@ the JavaScript happens to be.
mvn package -DgwtStyle=DETAILED mvn package -DgwtStyle=DETAILED
==== ====
Production Compile
------------------
*Always* use
----
mvn clean package
----
to create a production build. The `./to_hosted.sh` script that
setups the development environment for Eclipse hosted mode also
creates a state that produces a corrupt production build.
Final Setup Final Setup
----------- -----------

View File

@ -39,7 +39,7 @@ Maven from a source download obtained directly from Git:
==== ====
git clone git://android.git.kernel.org/tools/gerrit.git git clone git://android.git.kernel.org/tools/gerrit.git
cd gerrit cd gerrit
mvn package mvn clean package
cp target/gerrit-*.war ...YOUR.DEST.../gerrit.war cp target/gerrit-*.war ...YOUR.DEST.../gerrit.war
==== ====

View File

@ -10,6 +10,7 @@
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> <booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/> <stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;sourceLookupDirector&gt;&#10;&lt;sourceContainers duplicates=&quot;false&quot;&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;javaProject name=&amp;quot;gerrit&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;javaProject name=&amp;quot;gwtjsonrpc&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;javaProject name=&amp;quot;gwtorm&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;default/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.debug.core.containerType.default&quot;/&gt;&#10;&lt;/sourceContainers&gt;&#10;&lt;/sourceLookupDirector&gt;&#10;"/> <stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;sourceLookupDirector&gt;&#10;&lt;sourceContainers duplicates=&quot;false&quot;&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;javaProject name=&amp;quot;gerrit&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;javaProject name=&amp;quot;gwtjsonrpc&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;javaProject name=&amp;quot;gwtorm&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;default/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.debug.core.containerType.default&quot;/&gt;&#10;&lt;/sourceContainers&gt;&#10;&lt;/sourceLookupDirector&gt;&#10;"/>
<booleanAttribute key="org.eclipse.jdt.debug.ui.CONSIDER_INHERITED_MAIN" value="true"/>
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH"> <listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.jdt.launching.JRE_CONTAINER&quot; javaProject=&quot;gerrit&quot; path=&quot;1&quot; type=&quot;4&quot;/&gt;&#10;"/> <listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.jdt.launching.JRE_CONTAINER&quot; javaProject=&quot;gerrit&quot; path=&quot;1&quot; type=&quot;4&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.jdt.USER_LIBRARY/GWT_16&quot; path=&quot;3&quot; type=&quot;4&quot;/&gt;&#10;"/> <listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.jdt.USER_LIBRARY/GWT_16&quot; path=&quot;3&quot; type=&quot;4&quot;/&gt;&#10;"/>
@ -21,8 +22,8 @@
</listAttribute> </listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.maven.ide.eclipse.launchconfig.classpathProvider"/> <stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.maven.ide.eclipse.launchconfig.classpathProvider"/>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/> <booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.google.gwt.dev.GWTShell"/> <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.google.gwt.dev.HostedMode"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-out gwt_www com.google.gerrit.Gerrit/Gerrit.html"/> <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-war ${resource_loc:/gerrit/src/main/webapp} -startupUrl /Gerrit com.google.gerrit.Gerrit"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="gerrit"/> <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="gerrit"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.maven.ide.eclipse.launchconfig.sourcepathProvider"/> <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 -DGerritServer=${resource_loc:/gerrit/src/main/java/GerritServer.properties} -Dcom.google.gerrit.server.BecomeAnyAccountLoginServlet=true"/> <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx256M -DGerritServer=${resource_loc:/gerrit/src/main/java/GerritServer.properties} -Dcom.google.gerrit.server.BecomeAnyAccountLoginServlet=true"/>

View File

@ -22,8 +22,8 @@
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.maven.ide.eclipse.launchconfig.classpathProvider"/> <stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.maven.ide.eclipse.launchconfig.classpathProvider"/>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/> <booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.google.gwt.dev.GWTShell"/> <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.google.gwt.dev.HostedMode"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-out gwt_www com.google.gerrit.Gerrit/Gerrit.html"/> <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-war ${resource_loc:/gerrit/src/main/webapp} -startupUrl /Gerrit com.google.gerrit.Gerrit"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="gerrit"/> <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="gerrit"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.maven.ide.eclipse.launchconfig.sourcepathProvider"/> <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 -XstartOnFirstThread -DGerritServer=${resource_loc:/gerrit/src/main/java/GerritServer.properties} -Dcom.google.gerrit.server.BecomeAnyAccountLoginServlet=true"/> <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx256M -XstartOnFirstThread -DGerritServer=${resource_loc:/gerrit/src/main/java/GerritServer.properties} -Dcom.google.gerrit.server.BecomeAnyAccountLoginServlet=true"/>

36
pom.xml
View File

@ -268,12 +268,28 @@ limitations under the License.
<includes> <includes>
<include>log4j.properties</include> <include>log4j.properties</include>
<include>com/google/gerrit/client/GerritVersion.properties</include> <include>com/google/gerrit/client/GerritVersion.properties</include>
<include>com/google/gerrit/public/Gerrit.html</include>
</includes> </includes>
</resource> </resource>
</resources> </resources>
<plugins> <plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.2</version>
<configuration>
<filesets>
<fileset>
<directory>src/main/webapp</directory>
<includes>
<include>gerrit</include>
<include>WEB-INF/lib</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
@ -307,7 +323,7 @@ limitations under the License.
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId> <artifactId>maven-war-plugin</artifactId>
<configuration> <configuration>
<warSourceExcludes>.gwt-tmp/**</warSourceExcludes> <warSourceExcludes>WEB-INF/web-jetty.xml</warSourceExcludes>
<archiveClasses>true</archiveClasses> <archiveClasses>true</archiveClasses>
<archive> <archive>
<manifest> <manifest>
@ -379,6 +395,7 @@ limitations under the License.
<configuration> <configuration>
<tasks> <tasks>
<property name="d" location="${basedir}/target/${project.name}-${project.version}"/> <property name="d" location="${basedir}/target/${project.name}-${project.version}"/>
<property name="m" location="${d}/gerrit"/>
<property name="keyapplet" location="${basedir}/target/gerrit-keyapplet"/> <property name="keyapplet" location="${basedir}/target/gerrit-keyapplet"/>
<copy todir="${d}"> <copy todir="${d}">
@ -394,25 +411,18 @@ limitations under the License.
</fileset> </fileset>
</copy> </copy>
<move todir="${d}">
<fileset dir="${d}/com.google.gerrit.Gerrit">
<exclude name="Gerrit.html" />
<exclude name="hosted.html" />
</fileset>
</move>
<delete dir="${d}/com.google.gerrit.Gerrit" />
<apply executable="gzip" addsourcefile="false"> <apply executable="gzip" addsourcefile="false">
<arg value="-9"/> <arg value="-9"/>
<fileset dir="${d}" <fileset dir="${m}"
includes="**/*.html,**/*.css"/> includes="**/*.html,**/*.css"/>
<redirector> <redirector>
<inputmapper type="glob" from="*" to="${d}/*"/> <inputmapper type="glob" from="*" to="${m}/*"/>
<outputmapper type="glob" from="*" to="${d}/*.gz"/> <outputmapper type="glob" from="*" to="${m}/*.gz"/>
</redirector> </redirector>
</apply> </apply>
<zip <zip
destfile="${d}/gerrit-keyapplet.cache.jar" destfile="${m}/gerrit-keyapplet.cache.jar"
compress="true"> compress="true">
<fileset dir="${keyapplet}" includes="**/*"/> <fileset dir="${keyapplet}" includes="**/*"/>
</zip> </zip>

View File

@ -13,7 +13,7 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<module> <module rename-to="gerrit">
<inherits name='com.google.gwt.user.User'/> <inherits name='com.google.gwt.user.User'/>
<inherits name='com.google.gwtjsonrpc.GWTJSONRPC'/> <inherits name='com.google.gwtjsonrpc.GWTJSONRPC'/>
<inherits name='com.google.gwtorm.GWTORM'/> <inherits name='com.google.gwtorm.GWTORM'/>
@ -28,40 +28,4 @@
<extend-property name="locale" values="en"/> <extend-property name="locale" values="en"/>
<entry-point class='com.google.gerrit.client.Gerrit'/> <entry-point class='com.google.gerrit.client.Gerrit'/>
<servlet path='/Gerrit'
class='com.google.gerrit.server.HostPageServlet'/>
<servlet path='/login'
class='com.google.gerrit.server.OpenIdLoginServlet'/>
<servlet path='/ssh_info'
class='com.google.gerrit.server.ssh.SshServlet'/>
<servlet path='/cat/*'
class='com.google.gerrit.server.CatServlet'/>
<servlet path='/rpc/AccountService'
class='com.google.gerrit.server.AccountServiceSrv'/>
<servlet path='/rpc/AccountSecurity'
class='com.google.gerrit.server.AccountSecuritySrv'/>
<servlet path='/rpc/ChangeDetailService'
class='com.google.gerrit.server.ChangeDetailServiceSrv'/>
<servlet path='/rpc/ChangeListService'
class='com.google.gerrit.server.ChangeListServiceSrv'/>
<servlet path='/rpc/ChangeManageService'
class='com.google.gerrit.server.ChangeManageServiceSrv'/>
<servlet path='/rpc/GroupAdminService'
class='com.google.gerrit.server.GroupAdminServiceSrv'/>
<servlet path='/rpc/OpenIdService'
class='com.google.gerrit.server.OpenIdServiceSrv'/>
<servlet path='/rpc/PatchDetailService'
class='com.google.gerrit.server.PatchDetailServiceSrv'/>
<servlet path='/rpc/ProjectAdminService'
class='com.google.gerrit.server.ProjectAdminServiceSrv'/>
<servlet path='/rpc/SuggestService'
class='com.google.gerrit.server.SuggestServiceSrv'/>
<servlet path='/rpc/SystemInfoService'
class='com.google.gerrit.server.SystemInfoServiceSrv'/>
<!-- Hosted mode debugging ONLY -->
<servlet path='/__BecomeAnyAccount'
class='com.google.gerrit.server.BecomeAnyAccountLoginServlet'/>
</module> </module>

View File

@ -385,7 +385,7 @@ public class Gerrit implements EntryPoint {
if (GWT.isClient() && !GWT.isScript()) { if (GWT.isClient() && !GWT.isScript()) {
menuBar.addItem("Become", new Command() { menuBar.addItem("Become", new Command() {
public void execute() { public void execute() {
final String base = GWT.getModuleBaseURL(); final String base = GWT.getHostPageBaseURL();
Window.Location.assign(base + "__BecomeAnyAccount"); Window.Location.assign(base + "__BecomeAnyAccount");
} }
}); });

View File

@ -221,7 +221,7 @@ public class NewAgreementScreen extends AccountScreen {
agreementGroup.setVisible(true); agreementGroup.setVisible(true);
agreementHtml.setText(Gerrit.C.rpcStatusLoading()); agreementHtml.setText(Gerrit.C.rpcStatusLoading());
if (!url.startsWith("http:") && !url.startsWith("https:")) { if (!url.startsWith("http:") && !url.startsWith("https:")) {
url = GWT.getModuleBaseURL() + url; url = GWT.getHostPageBaseURL() + url;
} }
final RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, url); final RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, url);
rb.setCallback(new RequestCallback() { rb.setCallback(new RequestCallback() {

View File

@ -275,6 +275,7 @@ class AccountSecurityImpl extends BaseServiceImplementation implements
url.setLength(url.lastIndexOf("/")); // cut "AccountSecurity" url.setLength(url.lastIndexOf("/")); // cut "AccountSecurity"
url.setLength(url.lastIndexOf("/")); // cut "rpc" url.setLength(url.lastIndexOf("/")); // cut "rpc"
url.setLength(url.lastIndexOf("/")); // cut "gerrit"
url.append("/Gerrit#VE,"); url.append("/Gerrit#VE,");
try { try {

View File

@ -107,7 +107,7 @@ public class BecomeAnyAccountLoginServlet extends HttpServlet {
c.setPath(req.getContextPath() + "/"); c.setPath(req.getContextPath() + "/");
new AccountCookie(account.getId(), false).set(c, server); new AccountCookie(account.getId(), false).set(c, server);
rsp.addCookie(c); rsp.addCookie(c);
rsp.sendRedirect("Gerrit.html"); rsp.sendRedirect("Gerrit");
} else { } else {
rsp.sendError(HttpServletResponse.SC_NOT_FOUND); rsp.sendError(HttpServletResponse.SC_NOT_FOUND);

View File

@ -90,15 +90,7 @@ public class ChangeMail {
} }
public void setHttpServletRequest(final HttpServletRequest req) { public void setHttpServletRequest(final HttpServletRequest req) {
final StringBuffer url = req.getRequestURL(); myUrl = GerritServer.serverUrl(req);
final int rpc = url.indexOf("/rpc/");
if (rpc >= 0) {
url.setLength(rpc + 1); // cut "rpc/..."
}
if (url.length() == 0 || url.charAt(url.length() - 1) != '/') {
url.append('/');
}
myUrl = url.toString();
} }
public void setPatchSet(final PatchSet ps, final PatchSetInfo psi) { public void setPatchSet(final PatchSet ps, final PatchSetInfo psi) {

View File

@ -157,10 +157,11 @@ public class GerritServer {
if (s >= 0) { if (s >= 0) {
uri = uri.substring(0, s + 1); uri = uri.substring(0, s + 1);
} }
if (uri.endsWith("/rpc/")) { final String sfx = "/gerrit/rpc/";
// Nope, it was one of our RPC servlets. Drop the /rpc/ part too. if (uri.endsWith(sfx)) {
// Nope, it was one of our RPC servlets. Drop the rpc too.
// //
uri = uri.substring(0, uri.length() - 4); uri = uri.substring(0, uri.length() - (sfx.length() - 1));
} }
return uri; return uri;
} }

View File

@ -61,10 +61,10 @@ public class HostPageServlet extends HttpServlet {
final File sitePath = server.getSitePath(); final File sitePath = server.getSitePath();
canonicalUrl = server.getCanonicalURL(); canonicalUrl = server.getCanonicalURL();
final String hostPageName = "com/google/gerrit/public/Gerrit.html"; final String hostPageName = "WEB-INF/Gerrit.html";
hostDoc = HtmlDomUtil.parseFile(hostPageName); hostDoc = HtmlDomUtil.parseFile(getServletContext(), "/" + hostPageName);
if (hostDoc == null) { if (hostDoc == null) {
throw new ServletException("No " + hostPageName + " in CLASSPATH"); throw new ServletException("No " + hostPageName + " in webapp");
} }
fixModuleReference(hostDoc); fixModuleReference(hostDoc);
injectJson(hostDoc, "gerrit_gerritconfig", Common.getGerritConfig()); injectJson(hostDoc, "gerrit_gerritconfig", Common.getGerritConfig());
@ -159,9 +159,10 @@ public class HostPageServlet extends HttpServlet {
if (scriptNode == null) { if (scriptNode == null) {
throw new ServletException("No gerrit_module to rewrite in host document"); throw new ServletException("No gerrit_module to rewrite in host document");
} }
scriptNode.removeAttribute("id");
final String src = scriptNode.getAttribute("src"); final String src = scriptNode.getAttribute("src");
final InputStream in = getServletContext().getResourceAsStream("/" + src); InputStream in = getServletContext().getResourceAsStream("/" + src);
if (in == null) { if (in == null) {
throw new ServletException("No " + src + " in webapp root"); throw new ServletException("No " + src + " in webapp root");
} }
@ -182,7 +183,6 @@ public class HostPageServlet extends HttpServlet {
} }
final String vstr = ObjectId.fromRaw(md.digest()).name(); final String vstr = ObjectId.fromRaw(md.digest()).name();
scriptNode.removeAttribute("id");
scriptNode.setAttribute("src", src + "?content=" + vstr); scriptNode.setAttribute("src", src + "?content=" + vstr);
} }

View File

@ -30,6 +30,7 @@ import java.io.InputStreamReader;
import java.io.StringWriter; import java.io.StringWriter;
import java.util.zip.GZIPOutputStream; import java.util.zip.GZIPOutputStream;
import javax.servlet.ServletContext;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
@ -134,11 +135,12 @@ public class HtmlDomUtil {
return d; return d;
} }
/** Parse an XHTML file from our CLASSPATH and return the instance. */ /** Parse an XHTML file from our ServletContext and return the instance. */
public static Document parseFile(final String name) throws ServletException { public static Document parseFile(final ServletContext context,
final String name) throws ServletException {
final InputStream in; final InputStream in;
in = HtmlDomUtil.class.getClassLoader().getResourceAsStream(name); in = context.getResourceAsStream(name);
if (in == null) { if (in == null) {
return null; return null;
} }

View File

@ -94,7 +94,7 @@ public class UrlRewriteFilter implements Filter {
final HttpServletResponse rsp = (HttpServletResponse) srsp; final HttpServletResponse rsp = (HttpServletResponse) srsp;
final String pathInfo = pathInfo(req); final String pathInfo = pathInfo(req);
if (pathInfo.startsWith("/rpc/")) { if (pathInfo.startsWith("/gerrit/rpc/")) {
// RPC requests are very common in Gerrit 2, we want to make sure // RPC requests are very common in Gerrit 2, we want to make sure
// they run quickly by jumping through the chain as fast as we can. // they run quickly by jumping through the chain as fast as we can.
// //

View File

@ -4,7 +4,7 @@
<meta name="gwt:property" content="locale=en_US" /> <meta name="gwt:property" content="locale=en_US" />
<script id="gerrit_gerritconfig"></script> <script id="gerrit_gerritconfig"></script>
<script id="gerrit_myaccount"></script> <script id="gerrit_myaccount"></script>
<script id="gerrit_module" type="text/javascript" language="javascript" src="com.google.gerrit.Gerrit.nocache.js"></script> <script id="gerrit_module" type="text/javascript" language="javascript" src="gerrit/gerrit.nocache.js"></script>
<style id="gerrit_sitecss" type="text/css"></style> <style id="gerrit_sitecss" type="text/css"></style>
<link rel="icon" type="image/gif" href="favicon.ico" /> <link rel="icon" type="image/gif" href="favicon.ico" />
</head> </head>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<!--
This is for hosted mode debugging only.
-->
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
<Set name="extraClasspath">target/classes</Set>
</Configure>

View File

@ -54,6 +54,16 @@
<url-pattern>/login</url-pattern> <url-pattern>/login</url-pattern>
</servlet-mapping> </servlet-mapping>
<servlet>
<servlet-name>BecomeAnyAccount</servlet-name>
<servlet-class>com.google.gerrit.server.BecomeAnyAccountLoginServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>BecomeAnyAccount</servlet-name>
<url-pattern>/__BecomeAnyAccount</url-pattern>
</servlet-mapping>
<servlet> <servlet>
<servlet-name>ssh</servlet-name> <servlet-name>ssh</servlet-name>
<servlet-class>com.google.gerrit.server.ssh.SshServlet</servlet-class> <servlet-class>com.google.gerrit.server.ssh.SshServlet</servlet-class>
@ -91,7 +101,7 @@
</servlet> </servlet>
<servlet-mapping> <servlet-mapping>
<servlet-name>AccountService</servlet-name> <servlet-name>AccountService</servlet-name>
<url-pattern>/rpc/AccountService</url-pattern> <url-pattern>/gerrit/rpc/AccountService</url-pattern>
</servlet-mapping> </servlet-mapping>
<servlet> <servlet>
@ -101,7 +111,7 @@
</servlet> </servlet>
<servlet-mapping> <servlet-mapping>
<servlet-name>AccountSecurity</servlet-name> <servlet-name>AccountSecurity</servlet-name>
<url-pattern>/rpc/AccountSecurity</url-pattern> <url-pattern>/gerrit/rpc/AccountSecurity</url-pattern>
</servlet-mapping> </servlet-mapping>
<servlet> <servlet>
@ -111,7 +121,7 @@
</servlet> </servlet>
<servlet-mapping> <servlet-mapping>
<servlet-name>GroupAdminService</servlet-name> <servlet-name>GroupAdminService</servlet-name>
<url-pattern>/rpc/GroupAdminService</url-pattern> <url-pattern>/gerrit/rpc/GroupAdminService</url-pattern>
</servlet-mapping> </servlet-mapping>
<servlet> <servlet>
@ -121,7 +131,7 @@
</servlet> </servlet>
<servlet-mapping> <servlet-mapping>
<servlet-name>ChangeDetailService</servlet-name> <servlet-name>ChangeDetailService</servlet-name>
<url-pattern>/rpc/ChangeDetailService</url-pattern> <url-pattern>/gerrit/rpc/ChangeDetailService</url-pattern>
</servlet-mapping> </servlet-mapping>
<servlet> <servlet>
@ -131,7 +141,7 @@
</servlet> </servlet>
<servlet-mapping> <servlet-mapping>
<servlet-name>ChangeListService</servlet-name> <servlet-name>ChangeListService</servlet-name>
<url-pattern>/rpc/ChangeListService</url-pattern> <url-pattern>/gerrit/rpc/ChangeListService</url-pattern>
</servlet-mapping> </servlet-mapping>
<servlet> <servlet>
@ -141,7 +151,7 @@
</servlet> </servlet>
<servlet-mapping> <servlet-mapping>
<servlet-name>ChangeManageService</servlet-name> <servlet-name>ChangeManageService</servlet-name>
<url-pattern>/rpc/ChangeManageService</url-pattern> <url-pattern>/gerrit/rpc/ChangeManageService</url-pattern>
</servlet-mapping> </servlet-mapping>
<servlet> <servlet>
@ -151,7 +161,7 @@
</servlet> </servlet>
<servlet-mapping> <servlet-mapping>
<servlet-name>OpenIdService</servlet-name> <servlet-name>OpenIdService</servlet-name>
<url-pattern>/rpc/OpenIdService</url-pattern> <url-pattern>/gerrit/rpc/OpenIdService</url-pattern>
</servlet-mapping> </servlet-mapping>
<servlet> <servlet>
@ -161,7 +171,7 @@
</servlet> </servlet>
<servlet-mapping> <servlet-mapping>
<servlet-name>PatchDetailService</servlet-name> <servlet-name>PatchDetailService</servlet-name>
<url-pattern>/rpc/PatchDetailService</url-pattern> <url-pattern>/gerrit/rpc/PatchDetailService</url-pattern>
</servlet-mapping> </servlet-mapping>
<servlet> <servlet>
@ -171,7 +181,7 @@
</servlet> </servlet>
<servlet-mapping> <servlet-mapping>
<servlet-name>ProjectAdminService</servlet-name> <servlet-name>ProjectAdminService</servlet-name>
<url-pattern>/rpc/ProjectAdminService</url-pattern> <url-pattern>/gerrit/rpc/ProjectAdminService</url-pattern>
</servlet-mapping> </servlet-mapping>
<servlet> <servlet>
@ -181,7 +191,7 @@
</servlet> </servlet>
<servlet-mapping> <servlet-mapping>
<servlet-name>SuggestService</servlet-name> <servlet-name>SuggestService</servlet-name>
<url-pattern>/rpc/SuggestService</url-pattern> <url-pattern>/gerrit/rpc/SuggestService</url-pattern>
</servlet-mapping> </servlet-mapping>
<servlet> <servlet>
@ -191,6 +201,6 @@
</servlet> </servlet>
<servlet-mapping> <servlet-mapping>
<servlet-name>SystemInfoService</servlet-name> <servlet-name>SystemInfoService</servlet-name>
<url-pattern>/rpc/SystemInfoService</url-pattern> <url-pattern>/gerrit/rpc/SystemInfoService</url-pattern>
</servlet-mapping> </servlet-mapping>
</web-app> </web-app>

View File

Before

Width:  |  Height:  |  Size: 318 B

After

Width:  |  Height:  |  Size: 318 B

4
to_hosted.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
mvn war:inplace &&
rm -f src/main/webapp/WEB-INF/lib/gerrit-*.jar

View File

@ -16,7 +16,7 @@ fi
ctx="$jetty/contexts/gerrit.xml" && ctx="$jetty/contexts/gerrit.xml" &&
mvn package && mvn clean package &&
war=target/gerrit-*.war && war=target/gerrit-*.war &&
cp $war "$jetty/webapps/gerrit.war" && cp $war "$jetty/webapps/gerrit.war" &&