@@ -118,18 +118,14 @@ public JettyAppServer(String hostName, int httpPort, int httpsPort) {
118
118
handlers = new ContextHandlerCollection ();
119
119
120
120
Path webSrc = locate ("common/src/web" );
121
- ServletContextHandler defaultContext = addResourceHandler (
122
- DEFAULT_CONTEXT_PATH , webSrc );
121
+ ServletContextHandler defaultContext = new ServletContextHandler ();
122
+ handlers . addHandler ( defaultContext );
123
123
124
124
// Only non-null when running with bazel test.
125
125
Path runfiles = InProject .findRunfilesRoot ();
126
- if (runfiles != null ) {
127
- addResourceHandler (FILEZ_CONTEXT_PATH , runfiles );
128
- }
129
-
130
- addJsResourceHandler (JS_SRC_CONTEXT_PATH , "javascript" );
131
- addJsResourceHandler (CLOSURE_CONTEXT_PATH , "third_party/closure/goog" );
132
- addJsResourceHandler (THIRD_PARTY_JS_CONTEXT_PATH , "third_party/js" );
126
+ // if (runfiles != null) {
127
+ // addResourceHandler(FILEZ_CONTEXT_PATH, runfiles);
128
+ // }
133
129
134
130
TemporaryFilesystem tempFs = TemporaryFilesystem .getDefaultTmpFS ();
135
131
tempPageDir = tempFs .createTempDir ("pages" , "test" );
@@ -160,30 +156,24 @@ public JettyAppServer(String hostName, int httpPort, int httpsPort) {
160
156
Route .get ("/sleep" ).to (SleepingHandler ::new ),
161
157
Route .post ("/upload" ).to (UploadHandler ::new ),
162
158
Route .matching (req -> req .getUri ().startsWith ("/utf8/" )).to (() -> new Utf8Handler (webSrc , "/utf8/" )),
163
- Route .prefix (TEMP_SRC_CONTEXT_PATH ).to (Route .combine (generatedPages ))
164
- );
159
+ Route .prefix (TEMP_SRC_CONTEXT_PATH ).to (Route .combine (generatedPages )),
160
+ new CommonWebResources ());
161
+
162
+ // If we're not running inside `bazel test` this will be non-null
163
+ // if (runfiles != null) {
164
+ // route = Route.combine(
165
+ // route,
166
+ // Route.matching(req -> req.getUri().startsWith(FILEZ_CONTEXT_PATH)).to(new )
167
+ // )
168
+ // addResourceHandler(FILEZ_CONTEXT_PATH, runfiles);
169
+ // }
170
+
165
171
Route prefixed = Route .prefix (DEFAULT_CONTEXT_PATH ).to (route );
166
172
defaultContext .addServlet (new ServletHolder (new HttpHandlerServlet (Route .combine (route , prefixed ))), "/*" );
167
173
168
174
server .setHandler (handlers );
169
175
}
170
176
171
- private void addJsResourceHandler (String handlerPath , String dirPath ) {
172
- Path path ;
173
- try {
174
- path = locate (dirPath );
175
- } catch (WebDriverException e ) {
176
- // Ugly hack to get us started with bazel while sorting out missing data dependencies.
177
- if (Boolean .getBoolean (getClass ().getPackage ().getName () + ".ignoreMissingJsRoots" )
178
- && e .getCause () instanceof FileNotFoundException ) {
179
- System .err .println ("WARNING: failed to add resource handler " + handlerPath + ": " + e .getCause ());
180
- return ;
181
- }
182
- throw e ;
183
- }
184
- addResourceHandler (handlerPath , path );
185
- }
186
-
187
177
private static Optional <Integer > getEnvValue (String key ) {
188
178
return Optional .ofNullable (System .getenv (key )).map (Integer ::parseInt );
189
179
}
0 commit comments