<!-- This is a ant script that can be used to build and deploy a WAR file to Tomcat 
	 It is based on the Tomcat "deployer" distribution scripts  -->
<project name="Deployer" default="buildAndDeploy" basedir=".">

  <!-- The deployer.properties file is used to set (override) any of the
	   ant properties that are configured below  -->
  <property file="deployer.properties"/>

  <!-- Configure the directory into which the web application is built -->

  <!-- Configure the folder and context path for this application -->
  <property name="webapp"      value="jzos"/>
  <property name="contextRoot" value="/jzos" />

  <!-- The eclipse project name -->
  <property name="project_name" value="TomcatSample" />
	
  <!-- Configure properties to access the Manager application -->
  <property name="url"      value="http://localhost:8080/manager"/>
  <property name="username" value="tomcat"/>
  <property name="password" value="tomcat"/>

  <property name="webapp.path"     value="${basedir}/webapp"/>
  <property name="warFile"		   value="${basedir}/${webapp}.war" />

  <path id="deployer.classpath">
    <fileset dir="${basedir}/lib">
      <include name="*.jar"/>
    </fileset>
  </path>

  <!-- Configure the custom Ant tasks for the Manager application -->
  <taskdef resource="org/apache/catalina/ant/catalina.tasks"
           classpathref="deployer.classpath"/>

  <!-- Executable Targets -->

  <target name="buildAndDeploy" description="build and deploy war" depends="build,deploy"/>

  <target name="build" description="build war">

	    <jasper2 validateXml="false" 
	             uriroot="${webapp.path}" 
	             webXmlFragment="${webapp.path}/WEB-INF/generated_web.xml"
	             addWebXmlMappings="true"
	             outputDir="${basedir}/work" /> 

  		<eclipse.refreshLocal resource="${project_name}" depth="infinite" /> 
	    <!-- <validator path="${webapp.path}" /> -->

	    <jar destfile="${warFile}"
	         basedir="${webapp.path}" />
  		<eclipse.refreshLocal resource="${project_name}" depth="infinite" /> 

  </target>	
	
  <target name="deploy" description="Deploy web application">
    <deploy url="${url}" username="${username}" password="${password}"
            path="${contextRoot}" war="${warFile}" update="true" />
  </target>

  <target name="undeploy" description="Undeploy web application">
    <undeploy url="${url}" username="${username}" password="${password}"
              path="${contextRoot}"/>
  </target>

  <!-- Webapp lifecycle control -->
  <target name="start" description="Start web application">
    <start url="${url}" username="${username}" password="${password}"
           path="${contextRoot}"/>
  </target>
  <target name="reload" description="Reload web application">
    <reload url="${url}" username="${username}" password="${password}"
            path="${contextRoot}"/>
  </target>
  <target name="stop" description="Stop web application">
    <stop url="${url}" username="${username}" password="${password}"
          path="${contextRoot}"/>
  </target>

</project>
