<project name="blog1" default="build" basedir=".">
    <description>
        A simple build script.
    </description>
    <!-- set global properties for this build -->
    <!-- change as.home to point to appropriate location -->
    <property name="as.home" location="/home/ss141213/ROOT/WS/20051028/publish/glassfish"/>
    <property name="build" location="build"/>
    <target name="init">
        <!-- Create the build directory structure -->
        <mkdir dir="${build}/entities/META-INF"/>
        <mkdir dir="${build}/jpa-tag-lib/META-INF"/>
        <mkdir dir="${build}/web-app6/WEB-INF/classes"/>
        <mkdir dir="${build}/web-app6/WEB-INF/lib"/>
    </target>
    <target name="build-entities" depends="init"
        description="compile the entity beans and prepare a PU jar file.">
        <javac classpath="${as.home}/lib/javaee.jar"
            debug="yes"
            srcdir="entities/src"
            destdir="${build}/entities"/>
        <copy file="entities/persistence.xml" todir="${build}/entities/META-INF"/>
        <jar destfile="${build}/entities.jar" basedir="${build}/entities"/>
    </target>
    <target name="build-jpa-tag-lib" depends="init"
        description="compile the custom tags and prepare a tag library.">
        <javac classpath="${as.home}/lib/javaee.jar"
            debug="yes"
            srcdir="jpa-tag-lib/src"
            destdir="${build}/jpa-tag-lib"/>
        <copy file="jpa-tag-lib/jpa.tld" todir="${build}/jpa-tag-lib/META-INF"/>
        <jar destfile="${build}/jpa-tag-lib.jar" basedir="${build}/jpa-tag-lib"/>
    </target>
    <target name="build-web-app" depends="build-entities, build-jpa-tag-lib"
        description="compile the servlets and prepare a war file">
        <copy todir="${build}/web-app6/">
            <fileset dir="web-app6">
                <include name="**/*.html"/>
                <include name="**/*.jsp"/>
            </fileset>
        </copy>
        <copy file="${build}/entities.jar" todir="${build}/web-app6/WEB-INF/lib"/>
        <copy file="${build}/jpa-tag-lib.jar" todir="${build}/web-app6/WEB-INF/lib"/>
        <jar destfile="${build}/web-app6.war" basedir="${build}/web-app6"/>
    </target>
    <target name="build" depends="build-web-app"
        description="build the application"/>
    <target name="clean" description="clean up">
        <delete dir="${build}"/>
    </target>

    <!-- The following three targets are Sun Java System App Server specific -->
    <target name="verify" depends="build"
        description="verify compliance of the app against Java EE spec">
        <exec executable="${as.home}/bin/verifier"
            failonerror="true"
            vmlauncher="false">
            <arg line="-p -d ${build} ${build}/web-app6.war"/>
        </exec>
    </target>
    <target name="deploy" depends="build"
        description="deploy to Sun Java System Application Server">
        <exec executable="${as.home}/bin/asadmin"
            failonerror="true"
            vmlauncher="false">
            <arg line="deploy --user admin --password adminadmin --createtables ${build}/web-app6.war"/>
        </exec>
    </target>
    <target name="undeploy"
        description="undeploy from Sun Java System Application Server">
        <exec executable="${as.home}/bin/asadmin"
            failonerror="true"
            vmlauncher="false">
            <arg line="undeploy --user admin --password adminadmin --droptables web-app6"/>
        </exec>
    </target>

    <!-- This property needs to be set only if you want to generate tld documentation
          using tlddoc-->
    <property name="tlddoc.home" location="/home/ss141213/ROOT/software/taglibrarydoc-1_3/"/>
    <target name="doc-jpa-tag-lib" depends="build-jpa-tag-lib"
        description="generate documentation about the tag libraries">
    	<java fork="true" jar="${tlddoc.home}/tlddoc.jar"
            failonerror="false">
            <arg line="-d ${build}/jpa-tag-lib/doc"/>
            <arg value="${build}/jpa-tag-lib.jar"/>
	</java>
    </target>

</project>
