ant build.xml 之 tomcat工程的通用模板

类别:Java 点击:0 评论: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="${basedir}/WEB-INF/src"/>
  <property name="lib.dir"    value="${basedir}/WEB-INF/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>

本文地址:http://com.8s8s.com/it/it11340.htm