From: Jeff M. <cus...@us...> - 2002-08-29 12:17:24
|
Update of /cvsroot/mockobjects/mockobjects-java/doc In directory usw-pr-cvs1:/tmp/cvs-serv10521 Added Files: SiteHack.java site.xml Log Message: Add simplified build sytem for web site --- NEW FILE: SiteHack.java --- import java.io.*; import java.text.MessageFormat; /** * $Revision: 1.1 $ */ public class SiteHack { public static void main(String[] args) throws IOException { new SiteHack(args); } public SiteHack(String htmlFiles[]) throws IOException { String templateFile = htmlFiles[0]; MessageFormat template = new MessageFormat( readFileContent(templateFile)); for (int i = 1; i < htmlFiles.length; i++) { writeToFile(htmlFiles[i], template.format(new Object[]{ readFileContent(htmlFiles[i])})); } } private final void writeToFile(String fileName, String content) throws IOException { File outputFile = new File("out", new File(fileName).getName()); if (!outputFile.getParentFile().exists()) { outputFile.getParentFile().mkdirs(); } System.out.println("Writing file :" + outputFile.getCanonicalPath()); FileWriter writer = new FileWriter(outputFile); writer.write(content); writer.flush(); writer.close(); } private final String readFileContent(String fileName) throws IOException { StringBuffer fileContents = new StringBuffer(); System.out.println("Reading file :" + fileName); BufferedReader reader = new BufferedReader(new FileReader(fileName)); String line=null; while ((line = reader.readLine()) != null) { fileContents.append(line); fileContents.append("\r\n"); } return fileContents.toString(); } } --- NEW FILE: site.xml --- <?xml version="1.0" encoding="UTF-8"?> <project name="site" default="site" basedir="."> <target name="site"> <javac srcdir="."> <include name="SiteHack.java"/> </javac> <java classname="SiteHack"> <classpath path="."/> <arg value="html/template.txt"/> <arg value="html/alt.html"/> <arg value="html/changes.html"/> <arg value="html/coding_conventions.html"/> <arg value="html/downloads.html"/> <arg value="html/endotesting.html"/> <arg value="html/index.html"/> <arg value="html/license.html"/> <arg value="html/naming_conventions.html"/> <arg value="html/papers.html"/> <arg value="html/release_process.html"/> <arg value="html/todo.html"/> <arg value="html/index.html"/> </java> </target> </project> |