<project name="tomcat precompile" default="dist" basedir=".">
    <property name="tomcat.home" location="${tomcat.home}"/>
    <property name="webapp.name" value="${webapp.name}" />
    <property name="webapp.path" location="${tomcat.home}/webapps/${webapp.name}"/>

    <target name="jspc">
        <taskdef classname="org.apache.jasper.JspC" name="jasper2" >
            <classpath id="jspc.classpath">
                <pathelement location="${java.home}/../lib/tools.jar"/>
                <fileset dir="${tomcat.home}/bin">
		                    <include name="*.jar"/>
                </fileset>
                <fileset dir="${tomcat.home}/lib">
                    <include name="*.jar"/>
                </fileset>
            </classpath>
        </taskdef>

        <jasper2
             validateXml="false"
             uriroot="${webapp.path}"
             webXmlFragment="${webapp.path}/WEB-INF/generated_web.xml"
             outputDir="${webapp.path}/WEB-INF/src"
             >
        </jasper2>
        <property name="dir-path" value="${tomcat.home}/webapps/${webapp.name}/WEB-INF/src"/>
        <echo>Compile JSP in: ${dir-path}</echo>
        <javac destdir="${dir-path}"
               optimize="off"
               debug="on"
               failonerror="true"
               listfiles="yes"
               srcdir="${dir-path}">
            <include name="**/*.java"/>
            
   
            <classpath>
                <pathelement location="${webapp.path}/WEB-INF/classes"/>
                <fileset dir="${webapp.path}/WEB-INF/lib">
                    <include name="*.jar"/>
                </fileset>
                <pathelement location="${tomcat.home}/lib"/>
                <fileset dir="${tomcat.home}/lib">
                    <include name="*.jar"/>
                </fileset>
            </classpath>
            <include name="*.java" />
        </javac>
        <mkdir dir="${dir-path}/org/apache/jsp"/>
        <copy todir="${dir-path}" failonerror="false">
            <fileset dir="${dir-path}/org/apache/jsp">
                <include name="*.*"/>
            </fileset>
        </copy>
        <move todir="${tomcat.home}/work/Catalina/localhost/${webapp.name}">
          <fileset dir="${webapp.path}/WEB-INF/src">
            <include name="**/*.*"/>
          </fileset>
        </move>

        <!--<delete dir="${dir-path}/org" failonerror="false"/>-->
    </target>



    <target name="dist" depends="jspc" >
    </target>

</project>

