createReplace().set("${" + token + "}", value);
}
@Override
public void execute() throws BuildException {
Build build = getBuild();
// automatically setup substitution tokens
setToken(Toolkit.Key.name.projectId(), build.getPom().name);
setToken(Toolkit.Key.description.projectId(), build.getPom().description);
setToken(Toolkit.Key.url.projectId(), build.getPom().url);
setToken(Toolkit.Key.issuesUrl.projectId(), build.getPom().issuesUrl);
setToken(Toolkit.Key.inceptionYear.projectId(), build.getPom().inceptionYear);
setToken(Toolkit.Key.organization.projectId(), build.getPom().organization);
setToken(Toolkit.Key.organizationUrl.projectId(), build.getPom().organizationUrl);
setToken(Toolkit.Key.forumUrl.projectId(), build.getPom().forumUrl);
setToken(Toolkit.Key.socialNetworkUrl.projectId(), build.getPom().socialNetworkUrl);
setToken(Toolkit.Key.blogUrl.projectId(), build.getPom().blogUrl);
setToken(Toolkit.Key.ciUrl.projectId(), build.getPom().ciUrl);
setToken(Toolkit.Key.mavenUrl.projectId(), build.getPom().mavenUrl);
if (build.getPom().scm != null) {
setToken(Key.scmUrl.projectId(), build.getPom().scm.url);
}
setToken(Toolkit.Key.groupId.projectId(), build.getPom().groupId);
setToken(Toolkit.Key.artifactId.projectId(), build.getPom().artifactId);
setToken(Toolkit.Key.version.projectId(), build.getPom().version);
setToken(Toolkit.Key.coordinates.projectId(), build.getPom().getCoordinates());
setToken(Toolkit.Key.buildDate.projectId(), build.getBuildDateString());
setToken(Toolkit.Key.buildTimestamp.projectId(), build.getBuildTimestamp());
setToken(Toolkit.Key.releaseVersion.projectId(), build.getPom().releaseVersion);
setToken(Toolkit.Key.releaseDate.projectId(), build.getReleaseDateString());
setToken(Toolkit.Key.releaseDate.referenceId(), build.getReleaseDate());
setToken(Toolkit.Key.buildDate.referenceId(), build.getBuildDate());
for (Map.Entry<String, String> entry : build.getPom().getProperties().entrySet()) {
setToken(entry.getKey(), entry.getValue());
}
if (doc.name == null) {
doc.name = build.getPom().name;
}
if (doc.sourceDirectory == null) {
doc.sourceDirectory = build.getConfig().getSiteSourceDirectory();
}
if (doc.outputDirectory == null) {
doc.outputDirectory = build.getConfig().getSiteTargetDirectory();
}
if (doc.templateDirectory == null) {
doc.templateDirectory = new File(build.getConfig().getSiteSourceDirectory(), "templates");
}
doc.customLessFile = findFile(customLessFile);
if (logo != null) {
doc.logo = findFile(logo.getFile());
}
if (favicon != null) {
doc.favicon = findFile(favicon.getFile());
}
titleClass(build.getPom().name);
loadRuntimeDependencies(build,
new Dependency("mx:pegdown"),
new Dependency("mx:wikitext-core"),
new Dependency("mx:wikitext-twiki"),
new Dependency("mx:wikitext-textile"),
new Dependency("mx:wikitext-tracwiki"),
new Dependency("mx:wikitext-mediawiki"),
new Dependency("mx:wikitext-confluence"),
new Dependency("mx:freemarker"));
Dependency bootstrap = new Dependency("mx:bootstrap");
Dependency jquery = new Dependency("mx:jquery");
Dependency d3js = new Dependency("mx:d3js");
Dependency prettify = new Dependency("mx:prettify");
Dependency less = new Dependency("mx:lesscss-engine");
loadRuntimeDependencies(build, bootstrap, jquery, d3js, prettify, less);
if (doc.outputDirectory.exists()) {
FileUtils.delete(doc.outputDirectory);
}
doc.outputDirectory.mkdirs();
if (doc.logo != null && doc.logo.exists()) {
try {
FileUtils.copy(doc.outputDirectory, doc.logo);
} catch (IOException e) {
getConsole().error(e, "Failed to copy logo file!");
}
}
if (doc.favicon != null && doc.favicon.exists()) {
try {
FileUtils.copy(doc.outputDirectory, doc.favicon);
} catch (IOException e) {
getConsole().error(e, "Failed to copy favicon file!");
}
}
extractBootstrap(bootstrap, less, doc.outputDirectory);
extractJQuery(jquery, doc.outputDirectory);
extractD3js(d3js, doc.outputDirectory);
extractPrettify(prettify, doc.outputDirectory);
// setup prev/next pager links
preparePages(doc.structure.elements);
for (DocPage page : doc.freeformPages) {
// process out-of-structure template pages
prepareTemplatePage(page);
}
// block directives
createNomarkdown().configure("---NOMARKDOWN---", false, false);
createNomarkdown().configure("---ESCAPE---", true, false);
createNomarkdown().configure("---FIXED---", true, true);
createNomarkdown().configure("```", true, true);
doc.nomarkdowns.add(new ExcludeText("---EXCLUDE---"));
// wikitext transform directives
createWikiText().configureSyntax(Syntax.TWIKI);
createWikiText().configureSyntax(Syntax.TEXTILE);
createWikiText().configureSyntax(Syntax.TRACWIKI);
createWikiText().configureSyntax(Syntax.MEDIAWIKI);
createWikiText().configureSyntax(Syntax.CONFLUENCE);
// language syntax highlighting directives
createNomarkdown().configureLanguage("---CODE---", null);
createNomarkdown().configureLanguage("---CSS---", "lang-css");
createNomarkdown().configureLanguage("---JAVA---", "lang-java");
createNomarkdown().configureLanguage("---JSON---", "lang-json");
createNomarkdown().configureLanguage("---SQL---", "lang-sql");
createNomarkdown().configureLanguage("---WIKI---", "lang-wiki");
createNomarkdown().configureLanguage("---XML---", "lang-xml");
createNomarkdown().configureLanguage("---YAML---", "lang-yaml");
Docs.execute(build, doc, isVerbose());
writeDependenciesAsJson();
// add site resource directories
for (File dir : build.getConfig().getResourceDirectories(Scope.site)) {
createResource().createFileset().setDir(dir);
}
for (org.moxie.Resource resource : resources) {
File destdir = doc.outputDirectory;