else {
if (getDocletContext().getActiveSubTask().getMergeDir() != null) {
File mergeFile = new File(getDocletContext().getActiveSubTask().getMergeDir(), mergeFilePattern);
if (getEngine() instanceof TemplateParser) {
TemplateParser parser = (TemplateParser) getEngine();
// This avoids infinite loop when a merge file merge itself
if (parser.hasMergeFile(mergeFilePattern)) {
return null;
}
else {
parser.addMergeFile(mergeFilePattern);
}
}
if (mergeFile.exists()) {
log.debug("Merge file found in " + getDocletContext().getActiveSubTask().getMergeDir());
file = FileManager.getURLContent(mergeFile.toURL());
}
else {
// Backwards Compatibility - check for templates still using .j file extensions
if (mergeFilePattern.endsWith(".xdt")) {
mergeFile = new File(getDocletContext().getActiveSubTask().getMergeDir(),
mergeFilePattern.substring(0, mergeFilePattern.length() - 4) + ".j");
log.debug(".xdt mergefile not found, trying " + mergeFile.getName());
if (mergeFile.exists()) {
log.debug("Merge file found in " + getDocletContext().getActiveSubTask().getMergeDir());
file = FileManager.getURLContent(mergeFile.toURL());
}
else {
log.debug("Merge file NOT found in " + getDocletContext().getActiveSubTask().getMergeDir());
}
}
else {
log.debug("Merge file NOT found in " + getDocletContext().getActiveSubTask().getMergeDir());
}
}
}
}
if (file != null)
return file;
// was not found in mergedir, try the jar
URL jarResource = getClass().getResource('/' + mergeFilePattern);
if (jarResource != null) {
log.debug("Merge file found in jar");
if (getEngine() instanceof TemplateParser) {
TemplateParser parser = (TemplateParser) getEngine();
// This avoids infinite loop when a merge file merge itself
if (parser.hasMergeFile(mergeFilePattern)) {
return null;
}
else {
parser.addMergeFile(mergeFilePattern);
}
}
file = FileManager.getURLContent(jarResource);
}