// The directory that the html and resources are emitted into
File apidocOutputDir = new File(outputDirectory, "apidoc");
// Copy random resources
Scanner copyScanner = buildContext.newScanner(apidocDirectory, true);
copyScanner.setExcludes(new String[] { "apidoc_template.html", "**/*.md" });
copyScanner.scan();
for (String copyPath : copyScanner.getIncludedFiles()) {
File copyFrom = new File(apidocDirectory, copyPath);
File outFile = new File(apidocOutputDir, copyPath);
if (buildContext.isUptodate(outFile, copyFrom)) {
continue;
}
try {
InputStream in = new FileInputStream(copyFrom);
outFile.getParentFile().mkdirs();
OutputStream out = buildContext.newFileOutputStream(outFile);
IOUtil.copy(in, out);
in.close();
out.close();
} catch (IOException e) {
buildContext.addMessage(copyFrom, 0, 0, "Could not copy resource",
BuildContext.SEVERITY_ERROR, e);
}
}
// Look for all changed *.md files
Scanner inputScanner = buildContext.newScanner(apidocDirectory, false);
inputScanner.setIncludes(new String[] { "**/*.md" });
inputScanner.scan();
String[] dirtyPaths = inputScanner.getIncludedFiles();
if (dirtyPaths.length == 0) {
return;
}
apidocOutputDir.mkdirs();