private void transform(String fromFile, String toFile) {
if (fromFile == null) throw new BuildException("fromfile must be set");
if (toFile == null) throw new BuildException("tofile must be set");
try {
Project proj = getProject();
File tmp = new File(outdir, toFile).getParentFile();
if (!tmp.exists()) {
if (tmp.exists() || !tmp.mkdirs()) {
throw new IOException("Could not create " + tmp);
}
}
tmp = new File(toFile);
String pathToRoot = ".";
while ((tmp = tmp.getParentFile()) != null) {
pathToRoot = pathToRoot + "/..";
}
// Compute the relative path from directory holding the toFile
// to the javadoc direcotry.
String pathToOutDir = "";
tmp = new File(outdir, toFile).getParentFile();
while ((tmp = tmp.getParentFile()) != null && tmp.equals(outdir)) {
pathToOutDir = pathToOutDir + "../";
}
final String pathToJavadocDir = pathToOutDir + javadocRelPath;
String content = Util.loadFile(template.toString());
content = Util.replace(content, "$(LINKS)", links());
content = Util.replace(content, "$(MAIN)", Util.loadFile(fromFile));
for (Iterator it = fragments.keySet().iterator(); it.hasNext(); ) {
final String key = (String) it.next();
final HtmlFragment frag = (HtmlFragment) fragments.get(key);
final String linkText = frag.getLinkText();
if (null!=linkText && 0<linkText.length()) {
String fragLink = "<a href=\"#" +key +"\">" +linkText +"</a>";
content = Util.replace(content, "$("+key +"_LINK)", fragLink);
}
String fragCont = Util.loadFile(frag.getFromFile().getPath());
if (null!=fragCont && 0<fragCont.length()) {
fragCont = "<a name=\"" +key +"\"></a>\n" + fragCont;
}
content = Util.replace(content, "$("+key +")", fragCont);
}
content = Util.replace(content, "$(TITLE)", title);
content = Util.replace(content, "$(DESC)", description);
content = Util.replace(content, "$(TSTAMP)", TIMESTAMP);
content = Util.replace(content, "$(YEAR)", YEAR);
content = Util.replace(content, "$(USER)",
System.getProperty("user.name"));
content = Util.replace(content, "$(VERSION)",
proj.getProperty("version"));
content = Util.replace(content, "$(BASE_VERSION)",
proj.getProperty("base_version"));
content = Util.replace(content, "$(DISTNAME)",
proj.getProperty("distname"));
content = Util.replace(content, "$(DISTRIB_NAME)",
proj.getProperty("distrib.name"));
content = Util.replace(content, "$(RELEASE_NAME)",
proj.getProperty("release.name"));
content = Util.replace(content, "$(MESSAGE)",
proj.getProperty("release"));
content = Util.replace(content, "$(BUNDLE_LIST)", bundleList);
content = Util.replace(content, "$(ROOT)", pathToRoot);
content = Util.replace(content, "$(JAVADOC)",
proj.getProperty("JAVADOC"));
content = Util.replace(content, "$(CLASS_NAVIGATION)",
proj.getProperty("css_navigation_enabled"));
content = Util.replace(content, "$(SVN_REPO_URL)",
proj.getProperty("svn.repo.url"));
content = Util.replace(content, "$(SVN_TAG)",proj.getProperty("svn.tag"));
content = Util.replace(content, "$(JAVADOCPATH)", pathToJavadocDir);
content = Util.replace(content, "$(JAVADOCLINK)",
pathToJavadocDir + "/index.html?");
// Used for bundle_doc generation
if (do_manpage) {
content = Util.replace(content, "$(BUNDLE_NAME)", this.projectName);
content = Util.replace(content, "$(BUNDLE_VERSION)",
proj.getProperty("bmfa.Bundle-Version"));
final BundleArchives bas = getBundleArchives();
// Create links to jardoc for bundles built from this project
content = Util.replace(content, "$(BUNDLE_JARDOCS)", basToString(bas));
content = Util.replace(content, "$(BUNDLE_EXPORT_PACKAGE)",
getExportPkgs(bas, pathToJavadocDir));
// Replce H1-H3 headers to man page style, if manpage style
content = Util.replace(content, "<h1", "<h1 class=\"man\"");
content = Util.replace(content, "<H1", "<h1 class=\"man\"");
content = Util.replace(content, "<h2", "<h2 class=\"man\"");
content = Util.replace(content, "<H2", "<h2 class=\"man\"");
content = Util.replace(content, "<h3", "<h3 class=\"man\"");
content = Util.replace(content, "<H3", "<h3 class=\"man\"");
}
String s = proj.getProperty("navigation_pages");
String navEnabled = proj.getProperty("css_navigation_enabled");
String navDisabled = proj.getProperty("css_navigation_disabled");
// System.out.println("Navigation pages: " + s);
if (s != null) {
String[] navPages = Util.splitwords(s);
for (int i = 0; i < navPages.length; i++) {
// System.out.println("Checking: " + navPages[i]);