in doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java [192:267]
private void addModuleFiles(
File rootDir,
File moduleBasedir,
ParserModule module,
String excludes,
Map<String, DocumentRenderer> files,
boolean editable)
throws IOException, RendererException {
if (!moduleBasedir.exists() || ArrayUtils.isEmpty(module.getExtensions())) {
return;
}
String moduleRelativePath =
PathTool.getRelativeFilePath(rootDir.getAbsolutePath(), moduleBasedir.getAbsolutePath());
List<String> allFiles = FileUtils.getFileNames(moduleBasedir, "**/*", excludes, false);
for (String extension : module.getExtensions()) {
String fullExtension = "." + extension;
List<String> docs = filterExtensionIgnoreCase(allFiles, fullExtension);
// *.<extension>.vm
List<String> velocityFiles = filterExtensionIgnoreCase(allFiles, fullExtension + ".vm");
docs.addAll(velocityFiles);
for (String doc : docs) {
DocumentRenderingContext docRenderingContext = new DocumentRenderingContext(
moduleBasedir, moduleRelativePath, doc, module.getParserId(), extension, editable);
// TODO: DOXIA-111: we need a general filter here that knows how to alter the context
if (endsWithIgnoreCase(doc, ".vm")) {
docRenderingContext.setAttribute("velocity", "true");
}
String key = docRenderingContext.getOutputName();
if (files.containsKey(key)) {
DocumentRenderer docRenderer = files.get(key);
DocumentRenderingContext originalDocRenderingContext = docRenderer.getRenderingContext();
File originalDoc = new File(
originalDocRenderingContext.getBasedir(), originalDocRenderingContext.getInputName());
throw new RendererException("File '" + module.getSourceDirectory() + File.separator + doc
+ "' clashes with existing '" + originalDoc + "'.");
}
// -----------------------------------------------------------------------
// Handle key without case differences
// -----------------------------------------------------------------------
for (Map.Entry<String, DocumentRenderer> entry : files.entrySet()) {
if (entry.getKey().equalsIgnoreCase(key)) {
DocumentRenderingContext originalDocRenderingContext =
entry.getValue().getRenderingContext();
File originalDoc = new File(
originalDocRenderingContext.getBasedir(), originalDocRenderingContext.getInputName());
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
throw new RendererException("File '" + module.getSourceDirectory() + File.separator + doc
+ "' clashes with existing '" + originalDoc + "'.");
}
if (LOGGER.isWarnEnabled()) {
LOGGER.warn("File '" + module.getSourceDirectory() + File.separator + doc
+ "' could clash with existing '" + originalDoc + "'.");
}
}
}
files.put(key, new DoxiaDocumentRenderer(docRenderingContext));
}
}
}