<project name="grails-javadoc">



	<target name="javadoc">
		<delete dir="${grails.javadoc}"/>
		<mkdir dir="${grails.javadoc}"/>
        <mkdir dir="${grails.target}/docs/stubs"/>
        <mkdir dir="${grails.target}/docs/classes"/>

        <taskdef name="generatestubs" classname="org.codehaus.groovy.grails.cli.GenerateStubsTask">
             <classpath>
                 <fileset dir="${grails.dist}">
                       <include name="**/*.jar"/>
                  </fileset>
             </classpath>
             <classpath refid="classpath" />
        </taskdef>
        <!-- Need to generate the stubs for javadoc to work -->
        <generatestubs destdir="${grails.target}/docs/stubs">
            <classpath>
                <pathelement location="${grails.target}/docs/classes"/>
                <path refid="classpath"/>
            </classpath>
            <src>
                 <dirset dir="${grails.src}">
                    <exclude name="**/*.properties" />
                 </dirset>

            </src>
            <src path="${grails.src}"/>
        </generatestubs>


		<javadoc sourcepath="${grails.src}, ${grails.target}/docs/stubs" destdir="${grails.javadoc}" windowtitle="Grails ${grails.version}" source="1.5" encoding="UTF-8" access="package" author="true" version="true" use="true" defaultexcludes="true" breakiterator="true">
			<doctitle><![CDATA[<h1>Grails</h1>]]></doctitle>
			<bottom><![CDATA[<i>Copyright (c) 2005-2009 The Grails project</i>]]></bottom>
			<classpath refid="classpath"/>
			<packageset dir="${grails.target}/docs/stubs">
				<include name="org/codehaus/groovy/grails/**"/>
				<include name="grails/**"/>
			</packageset>
			<packageset dir="${grails.src}">
				<include name="org/codehaus/groovy/grails/**"/>
				<include name="grails/**"/>
			</packageset>
			<link href="http://java.sun.com/j2ee/1.4/docs/api"/>
			<link href="http://java.sun.com/j2se/1.5.0/docs/api"/>
			<link href="http://static.springframework.org/spring/docs/2.5.x/api"/>
			<tag name="todo" description="To do:" />
		</javadoc>

       <delete dir="${grails.target}/docs"/>

	</target>
	
	<target name="gdoc">
		<available file="../grails-doc" type="dir"
		           property="grails.doc.present"/>
		<antcall target="--gdoc" />
	</target>
	
	<target name="--gdoc" if="grails.doc.present">
		<ant target="distclean" dir="../grails-doc" inheritAll="false" />
		<ant target="dist-nojavadoc" dir="../grails-doc" inheritAll="false">		
			<property name="base.dir" value="../grails-doc" />
		</ant>
		<copy todir="doc">
			<fileset dir="../grails-doc/output" />
		</copy>		
	</target>
	

</project>
