ant build.xml 的 tomcat项目的通用模板

<?xml version="1.0" ?>
<project name="structs" default="compile" basedir=".">
  <property name="app.name"      value="structs"/>
  <property name="app.path"      value="/${app.name}"/>
  <property name="app.version"   value="2.0-dev"/>
  <property name="catalina.home" value="D:/Tomcat 5.0"/> 
 
  <property name="manager.url"   value="http://localhost:8080/manager"/>
  <property name="manager.password"   value="admin"/><!-- UPDATE THIS! -->
  <property name="manager.username"   value="admin"/><!-- UPDATE THIS! -->
  <property name="src.dir"      value="src"/>
  <property name="lib.dir"    value="lib"/>
  <property name="class.dir"    value="${basedir}/WEB-INF/classes"/>

 

  <taskdef name="install" classname="org.apache.catalina.ant.InstallTask"/>
  <taskdef name="list"    classname="org.apache.catalina.ant.ListTask"/>
  <taskdef name="reload"  classname="org.apache.catalina.ant.ReloadTask"/>
  <taskdef name="remove"  classname="org.apache.catalina.ant.RemoveTask"/>


  <property name="compile.debug"       value="true"/>
  <property name="compile.deprecation" value="false"/>
  <property name="compile.optimize"    value="true"/>

  <path id="compile.classpath">
   <!--
    lib path of tomcat
   -->
    <pathelement location="${catalina.home}/common/classes"/>
    <fileset dir="${catalina.home}/common/endorsed">
      <include name="*.jar"/>
    </fileset>
    <fileset dir="${catalina.home}/common/lib">
      <include name="*.jar"/>
    </fileset>
    <pathelement location="${catalina.home}/shared/classes"/>
    <fileset dir="${catalina.home}/shared/lib">
      <include name="*.jar"/>
    </fileset>
   <!--
       project lib path 
      -->
    <fileset dir="${lib.dir}">
      <include name="*.jar"/>
    </fileset>
  </path>


  <target name="all" depends="clean,compile"
   description="Clean build and dist directories, then compile"/>

 


  <target name="clean"
   description="Delete old build and dist directories">
    <delete dir="${class.dir}"  includes="**/*.class"/>
  </target>


  <target name="compile"
   description="Compile Java sources">

    <!-- Compile Java classes as necessary -->
    <mkdir    dir="${class.dir}"/>
    <javac srcdir="${src.dir}"
          destdir="${class.dir}"
            debug="${compile.debug}"
      deprecation="${compile.deprecation}"
         optimize="${compile.optimize}">
        <classpath refid="compile.classpath"/>
    </javac>

    <copy  todir="${class.dir}">
      <fileset dir="${src.dir}" excludes="**/*.java"/>
    </copy>
  </target>
 
 
  <target name="install"
   description="Install application to servlet container">

    <install url="${manager.url}"
        username="${manager.username}"
        password="${manager.password}"
            path="${app.path}"
             war="file://${basedir}"/>
  </target> 

 

  <target name="reload"
   description="Reload application on servlet container">

    <reload url="${manager.url}"
       username="${manager.username}"
       password="${manager.password}"
           path="${app.path}"/>
  </target>


  <target name="remove"
   description="Remove application on servlet container">

    <remove url="${manager.url}"
       username="${manager.username}"
       password="${manager.password}"
           path="${app.path}"/>

  </target>


</project>

说明:以上build.xml需放在工程的根目录下,即与src、lib、WebRoot目录平级

你可能感兴趣的:(java,tomcat,xml,ant)