Source:
public Collection<GeneratedFile> generateFiles(SensorContext sensorContext, List<File> javaClasspath) { List<Path> jspFiles = jspFiles(sensorContext.fileSystem()); LOG.debug("Found JSP files.", jspFiles.size()); if (jspFiles.isEmpty()) { return Collections.emptyList(); } Path outputDir = outputDir(sensorContext); File baseDir = sensorContext.fileSystem().baseDir(); ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try { ClassLoader classLoader = initClassLoader(javaClasspath); Thread.currentThread().setContextClassLoader(classLoader); JspFactory.setDefaultFactory(new JspFactoryImpl()); JspCServletContext servletContext = new ServletContext(toUrl(baseDir), classLoader); JasperOptions options = new JasperOptions(servletContext, outputDir); JspRuntimeContext runtimeContext = new JspRuntimeContext(servletContext, options); boolean errorTranspiling = false; for (Path file : jspFiles) { LOG.debug("Transpiling JSP: {}", file); try { String relativePath = file.toAbsolutePath().toString().substring(baseDir.getAbsolutePath().length()); JspCompilationContext compilationContext = new JspCompilationContext(relativePath, options, servletContext, null, runtimeContext); compilationContext.setClassLoader(classLoader); Compiler compiler = compilationContext.createCompiler(); compiler.compile(false, true); } catch (Exception e) { errorTranspiling = true; LOG.debug("Error transpiling " + file, e); } } if (errorTranspiling) { LOG.warn("Some JSP pages failed to transpile. Enable debug log for details."); } return findGeneratedFiles(outputDir); } catch (Exception e) { LOG.warn("Failed to transpile JSP files.", e); return Collections.emptyList(); } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } }

Target:
public Collection<GeneratedFile> generateFiles(SensorContext sensorContext, List<File> javaClasspath) { List<Path> jspFiles = jspFiles(sensorContext.fileSystem()); LOG.debug("Found JSP files.", jspFiles.size()); if (jspFiles.isEmpty()) { return Collections.emptyList(); } Path uriRoot = findWebInfParentDirectory(sensorContext.fileSystem()) .orElse(sensorContext.fileSystem().baseDir().getAbsoluteFile().toPath()); LOG.debug("Context root set to {}", uriRoot); Path outputDir = outputDir(sensorContext); ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try { ClassLoader classLoader = initClassLoader(javaClasspath); Thread.currentThread().setContextClassLoader(classLoader); JspFactory.setDefaultFactory(new JspFactoryImpl()); JspCServletContext servletContext = new ServletContext(uriRoot.toUri().toURL(), classLoader); JasperOptions options = getJasperOptions(outputDir, servletContext); JspRuntimeContext runtimeContext = new JspRuntimeContext(servletContext, options); boolean errorTranspiling = false; for (Path jsp : jspFiles) { try { transpileJsp(jsp, uriRoot, classLoader, servletContext, options, runtimeContext); } catch (Exception e) { errorTranspiling = true; LOG.debug("Error transpiling " + jsp, e); } } if (errorTranspiling) { LOG.warn("Some JSP pages failed to transpile. Enable debug log for details."); } return findGeneratedFiles(outputDir, uriRoot); } catch (Exception e) { LOG.warn("Failed to transpile JSP files.", e); return Collections.emptyList(); } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } }