<project default="toc" basedir=".">

	<target name="init">
	</target>
	
	<target name="toc" depends="init,compile">
		<echo file="tocapi.xml"><![CDATA[
<toc label="JavaDoc">
]]></echo>
		<java classname="BuildAPITOC" classpath="." output="tocapi.xml" append="true">
			<arg value="http://download.eclipse.org/rt/ecf/3.5Test/javadoc/package-list"/>
		</java>
		<echo file="tocapi.xml" append="true"><![CDATA[
</toc>
]]></echo>
	</target>

	<target name="compile">
		<echo file="BuildAPITOC.java"><![CDATA[
import java.io.*;
import java.net.URL;
public class BuildAPITOC {
	public static void main(String[] args) throws Exception {
	    System.out.println("args[0] is "+args[0]);
	    URL url = new URL(args[0]);
		BufferedReader r = new BufferedReader(new InputStreamReader(url.openStream()));
		String line;
		try {
			while ((line = r.readLine()) != null)
				System.out.println("<topic label=\"" + line + "\" href=\"http://download.eclipse.org/rt/ecf/latest/javadoc/" + line.replace('.', '/') + "/package-summary.html\"/>");
		} finally {
			r.close();
		}
	}
}
]]></echo>
		<javac srcDir="." includes="BuildAPITOC.java"/>
	</target>
	
	<target name="clean">
		<delete>
			<fileset dir="." includes="BuildAPITOC.*,tocapi.xml"/>
		</delete>
	</target>
</project>