<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE project [ <!ENTITY include SYSTEM "../../../common.xml"> ]>

  <!-- ======================================================= -->
  <!--  Sun ONE Application Server Sample Application build xml -->
  <!-- ======================================================= -->

  <project name="webapps-simple" default="core" basedir=".">

  <property name="sample.home" value="../../../"/>
  <!-- ======================================================= -->
  <!--                   App name-dependent settings.                              -->
  <!-- ======================================================= -->

  <property name="appname" value="webapps-simple"/>

  <!-- mail properties to be read from properties file -->
  <property file="./mail.properties"/>

  <target name="setup_mail_properties">
    <propertyfile file="./mail.properties">
      <entry key="mailhost" value="${mailhost}"/>
      <entry key="fromaddress" value="${fromaddress}"/>
      <entry key="mailuser" value="${mailuser}"/>
      <entry key="debug" value="${debug}"/>
      <entry key="enabled" value="${enabled}"/>
    </propertyfile>
  </target>

  <!-- ======================================================= -->
  <!--                   Package directory structures of interest.         -->
  <!-- ======================================================= -->

  <property name="app.pkg" value="samples/webapps/simple"/>
  <property name="war.pkg" value="samples/webapps/simple"/>
 
  <!-- ======================================================= -->
  <!--          property need to build war deployment.         -->
  <!-- ======================================================= -->

  <property name="apptype"     value="web"/>
  <property name="verify.file"  value="../${appname}.war"/>
  <property name="deploy.file"  value="../${appname}.war"/>

  <!-- ======================================================= -->
  <!--                  Java Doc properties .                                          -->
  <!-- ======================================================= -->
  
  <property name="sample.name" value="Webapps Simple Samples"/>
  <property name="javadoc.pkgnames" value="samples.webapps.simple.*" />

  <!-- ======================================================= -->
  <!--                  Xml files properties .                 -->
  <!-- ======================================================= -->
  
  <property name="warDD" value="web.xml,sun-web.xml"/>
 
  <!-- ======================================================= -->
  <!--                          Include common.xml             -->
  <!-- ======================================================= -->
 
  &include;

  <!-- ======================================================= -->
  <!--                    For War File                         -->
  <!-- ======================================================= -->
  
  <target name="create_war" 
          depends="clean_war_common,check_warfile,copy_docroot,copy_warfiles,copy_plugin,copy_ejbjar_war">
    <mkdir dir="${assemble.war}"/>
    <copy todir="${assemble.war}/WEB-INF/">
      <fileset dir="." includes="${warDD}"/>
    </copy>
    <jar jarfile="../${war}"
       basedir="${assemble.war}" />
    <move file="../${war}" todir="${assemble.war}"/>
    <copy file="${assemble.war}/${war}" tofile="../${war}"/>
    <property name="war.done" value="true"/>
  </target>

  <target name="copy_plugin" if="warfiles.present">
    <copy todir="${assemble.war}/jsp/plugin/applet">
      <fileset dir="${build.classesdir}/" includes="**/Clock2.class"/>
    </copy>
  </target>

  <!-- ======================================================= -->
  <!--                    For JavaMail Sample                  -->
  <!-- ======================================================= -->
 
  <target name="create-javamail-resource">
    <antcall target="admin_command_common">
      <param name="admin.command" value="create-javamail-resource
       --mailhost ${mailhost} --mailuser ${mailuser}
       --fromaddress ${fromaddress} --storeprotocol=imap
       --storeprotocolclass=com.sun.mail.imap.IMAPStore --transprotocol=smtp
       --transprotocolclass=com.sun.mail.smtp.SMTPTransport
       --debug=false --enabled=true
       --instance ${sunone.instance} mail/Session"
      />
    </antcall>
  </target>

  <target name="delete-javamail-resource">
    <antcall target="admin_command_common">
      <param name="admin.command" value="delete-javamail-resource
      mail/Session --instance ${sunone.instance}" />
    </antcall>
  </target>


  <!-- ======================================================= -->
  <!--          Tagets to build and deploy sample application  -->
  <!-- ======================================================= -->
  
  <target name="clean" depends="clean_common"/>
  <target name="init" depends="init_common"/>
  <target name="compile" depends="compile_common"/>
  <target name="javadocs" depends="javadocs_common"/>
  <target name="war" depends="init,create_war"/>
  <target name="ear" depends="init,war,create_ear_common"/>
  <target name="reconfig" depends="reconfig_common"/>
  <target name="core" depends="compile,war" />
<!--
  <target name="deploy" depends="deploy_common"/>
  <target name="undeploy" depends="undeploy_common"/>
-->
  <target name="deploy" depends="init_common,deploy_common,create-javamail-resource,reconfig"/>
  <target name="undeploy" depends="init_common,undeploy_common,delete-javamail-resource,reconfig"/>

  <target name="verify" depends="verify_common"/>
  <target name="all" depends="core,javadocs,verify,deploy"/>
</project>

