in src/main/java/org/apache/maven/plugins/site/run/SiteRunMojo.java [118:174]
private WebAppContext createWebApplication() throws MojoExecutionException {
File webXml = new File(tempWebappDirectory, "WEB-INF/web.xml");
webXml.getParentFile().mkdirs();
try (InputStream inStream = getClass().getResourceAsStream("/run/web.xml"); //
FileOutputStream outStream = new FileOutputStream(webXml)) {
IOUtil.copy(inStream, outStream);
} catch (IOException e) {
throw new MojoExecutionException("Unable to construct temporary webapp for running site", e);
}
WebAppContext webapp = new WebAppContext();
webapp.setContextPath("/");
webapp.setResourceBase(tempWebappDirectory.getAbsolutePath());
webapp.setAttribute(DoxiaFilter.OUTPUT_DIRECTORY_KEY, tempWebappDirectory);
webapp.setAttribute(DoxiaFilter.SITE_RENDERER_KEY, siteRenderer);
webapp.getInitParams().put("org.mortbay.jetty.servlet.Default.useFileMappedBuffer", "false");
// For external reports
project.getReporting().setOutputDirectory(tempWebappDirectory.getAbsolutePath());
List<Locale> localesList = getLocales();
webapp.setAttribute(DoxiaFilter.LOCALES_LIST_KEY, localesList);
try {
Map<String, DoxiaBean> i18nDoxiaContexts = new HashMap<>();
for (Locale locale : localesList) {
SiteRenderingContext i18nContext = createSiteRenderingContext(locale);
i18nContext.setInputEncoding(getInputEncoding());
i18nContext.setOutputEncoding(getOutputEncoding());
File outputDirectory = getOutputDirectory(locale);
List<MavenReportExecution> reports = getReports(outputDirectory);
Map<String, DocumentRenderer> i18nDocuments = locateDocuments(i18nContext, reports, locale);
DoxiaBean doxiaBean = new DoxiaBean(i18nContext, i18nDocuments);
if (!locale.equals(SiteTool.DEFAULT_LOCALE)) {
i18nDoxiaContexts.put(locale.toString(), doxiaBean);
} else {
i18nDoxiaContexts.put("default", doxiaBean);
}
if (!locale.equals(SiteTool.DEFAULT_LOCALE)) {
siteRenderer.copyResources(i18nContext, new File(tempWebappDirectory, locale.toString()));
} else {
siteRenderer.copyResources(i18nContext, tempWebappDirectory);
}
}
webapp.setAttribute(DoxiaFilter.I18N_DOXIA_CONTEXTS_KEY, i18nDoxiaContexts);
} catch (Exception e) {
throw new MojoExecutionException("Unable to set up webapp", e);
}
return webapp;
}