再转一个ant脚本

出处:http://blog.sina.com.cn/s/blog_552c41be010002bf.html
<?xml version="1.0"?>
<project name="ephmisWeb" basedir="." default="deploy">
 <property file="build.properties" />
 <property name="src.dir" value="Java Source" />
 <property name="web.dir" value="Web Content" />
 <property name="build.javadoc" value="JavaDoc" />
 <property name="build.dir" value="${web.dir}/WEB-INF/classes" />
 <property name="lib.dir" value="ext/lib" />
 <property name="libext.dir" value="ext/libext" />
 <path id="master-classpath">
  <fileset dir="${lib.dir}">
   <include name="*.jar" />
  </fileset>
  <fileset dir="${libext.dir}">
   <include name="*.jar" />
  </fileset>
  <!-- We need the servlet API classes:        -->
  <!--   for Tomcat 4.1 use servlet.jar        -->
  <!--   for Tomcat 5.0 use servlet-api.jar    -->
  <!--   for Other app server - check the docs -->
  <fileset dir="${tomcat.home}/common/lib">
   <include name="*.jar" />
  </fileset>
  <fileset dir="${tomcat.home}/server/lib">
   <include name="*.jar" />
  </fileset>
  <fileset dir="${tomcat.home}/shared/lib">
   <include name="*.jar" />
  </fileset>
  <pathelement path="${build.dir}" />
 </path>
 <target name="build" description="Compile main source tree java files">
  <delete>
   <fileset dir="${src.dir}" includes="**/zzz*.*" />
  </delete>
  <mkdir dir="${tomcat.home}/webapps/${ant.project.name}/WEB-INF/classes" />
  <javac destdir="${tomcat.home}/webapps/${ant.project.name}/WEB-INF/classes" target="1.3" debug="true" deprecation="false" optimize="false" failonerror="true">
   <src path="${src.dir}" />
   <classpath refid="master-classpath" />
  </javac>
 </target>
 <target name="deploy" depends="build" description="Deploy application">
  <copy todir="${tomcat.home}/webapps/${ant.project.name}" preservelastmodified="true">
   <fileset dir="${web.dir}">
    <include name="**/*.*" />
    <exclude name="**/zzz*.*" />
    <exclude name="notice.txt" />
    <exclude name="Validator.chm" />
   </fileset>
  </copy>
  <copy todir="${tomcat.home}/webapps/${ant.project.name}/WEB-INF/classes" preservelastmodified="true">
   <fileset dir="${src.dir}">
    <include name="*.properties" />
   </fileset>
  </copy>
  <copy todir="${tomcat.home}/webapps/${ant.project.name}/WEB-INF/lib" preservelastmodified="true">
   <fileset dir="${lib.dir}">
    <include name="*.*" />
   </fileset>
  </copy>
 </target>
 <target name="deploywar" depends="build" description="Deploy application as a WAR file">
  <war destfile="${ant.project.name}.war" webxml="${web.dir}/WEB-INF/web.xml">
   <fileset dir="${web.dir}">
    <include name="**/*.*" />
   </fileset>
  </war>
  <copy todir="${deploy.path}" preservelastmodified="true">
   <fileset dir=".">
    <include name="*.war" />
   </fileset>
  </copy>
 </target>
 <target name="clean">
  <delete includeEmptyDirs="true">
   <fileset dir="${tomcat.home}/work/Standalone/localhost/${ant.project.name}" />
  </delete>
 </target>
 <target name="javadoc">
  <mkdir dir="${build.javadoc}" />
  <javadoc packagenames="com.*,eph.*" private="true" destdir="${build.javadoc}" author="true" version="true" splitindex="true" noindex="false" maxmemory="256m">
   <classpath refid="master-classpath" />
   <sourcepath>
    <pathelement path="${src.dir}" />
   </sourcepath>
  </javadoc>
 </target>
 <target name="todo" description="todolist">
  <taskdef name="documentdoclet" classname="xdoclet.modules.doc.DocumentDocletTask" classpathref="master-classpath" />
  <documentdoclet destdir="ToDo">
   <fileset dir="src">
    <include name="**/*.java" />
   </fileset>
   <info header="Todo list" projectname="ephmisWeb" tag="todo" />
  </documentdoclet>
 </target>
 <target name="oracle">
  <!-- Read the properties from the release of the ephmis_config -->
  <property file="${tomcat.home}/webapps/${ant.project.name}/WEB-INF/classes/ephmis_config.properties" prefix="ephmis_config"/>
  <echo message="${ephmis_config.url}"/>
  <echo message="${ephmis_config.username}"/>
  <echo message="${ephmis_config.password}"/>   
 </target>

<!--call choose example  -->
 <target name="foo-upload"><echo>FOO upload</echo></target>
    <target name="bar-upload"><echo>BAR upload</echo></target>
    <target name="test-upload"><echo>TEST upload</echo></target>
    <target name="call">
        <input message="Please choose the server "
               validargs="foo,bar,test"
               addproperty="server"
               defaultvalue="test"
        />
        <antcall target="${server}-upload"/>
    </target>
<!--end call  -->
</project>

你可能感兴趣的:(tomcat,xml,servlet,ant,脚本)