<project default="toc" basedir=".">
	
	<target name="init">
		<property name="dest.path" location="${basedir}/html/reference/extension-points"/>
		<uptodate property="BuildExtPointTOC.uptodate" targetfile="BuildExtPointTOC.class">
			<srcfiles dir="${dest.path}" includes="*.html"/>
		</uptodate>
	</target>

	<target name="toc" depends="init,compile">
		<echo file="tocextpoint.xml"><![CDATA[
<toc label="Extension Points">
]]></echo>
		<java classname="BuildExtPointTOC" classpath="." output="tocextpoint.xml" append="true">
			<arg value="${dest.path}"/>
		</java>
		<echo file="tocextpoint.xml" append="true"><![CDATA[
</toc>
]]></echo>
	</target>
	
	<target name="compile" unless="BuildExtPointTOC.uptodate">
		<echo file="BuildExtPointTOC.java"><![CDATA[
import java.io.*;
public class BuildExtPointTOC {
	public static void main(String[] args) throws Exception {
		File dir = new File(args[0]);
		File[] files = dir.listFiles(new FileFilter() {
			public boolean accept(File file) {
				return file.isFile() && file.getName().endsWith(".html");
			}
		});
		for (int i = 0; i < files.length; ++i) {
			String name = files[i].getName();
			System.out.println("<topic label=\"" + name.substring(0, name.indexOf('.')).replace('_', '.') + "\" href=\"html/reference/extension-points/" + name + "\"/>");
		}
	}
}
]]></echo>
		<javac srcDir="." includes="BuildExtPointTOC.java"/>
	</target>
	
	<target name="clean">
		<delete>
			<fileset dir="." includes="BuildExtPointTOC.*,tocextpoint.xml"/>
		</delete>
	</target>
</project>