build.xml类 参考 (生成war)

来源:互联网 发布:知其不可奈何安之若命 编辑:程序博客网 时间:2024/06/06 05:40

<?xml version="1.0" ?>
<project name="LpsPushService_pushmarketing" default="build" basedir="..">
 
 <!-- set global properties for this build -->
 <!--<property name="LpsPushService_common2.location" value="../LpsPushService_common2" />-->

 <!-- 发布WEB路径 -->
 <property name="DEPLOY_PATH" value="${basedir}/dist/lps-psb-pushmarketing.war" />
 <property name="DEPLOY_ZIP_FILE" value="${basedir}/dist/lps-psb-pushmarketing.war.zip" />

 <!-- 源WEB路径 -->
 <property name="WEB_PATH" value="${basedir}/WebRoot" />

 <!-- 源java文件路径 -->
 <property name="SRC_PATH" value="${basedir}/src" />

 <property name="DES_WEB_INF_PATH" value="${DEPLOY_PATH}/WEB-INF/" />
 <property name="DES_LIB_PATH" value="${DES_WEB_INF_PATH}/lib/" />
 <property name="DES_CLASS_PATH" value="${DES_WEB_INF_PATH}/classes/" />

 <!-- 定义classpath -->
 <path id="classpath">
  <!--<fileset file="${LpsPushService_common2.location}/dist/lps-psb-common.jar" />
  <fileset file="${LpsPushService_common2.location}/lib/*.jar" /> -->
  <fileset file="${WEB_PATH}/WEB-INF/lib/*.jar" />
 </path>

 <!-- 初始化 -->
 <target name="init">
  <mkdir dir="${DES_LIB_PATH}" />
  <mkdir dir="${DES_CLASS_PATH}" />
 </target>

 <target name="clean">
  <delete dir="${basedir}/dist/*" />
 </target>

 <!-- 编译类 -->
 <target name="compile" depends="clean,init" description="compile the source files">
  <javac srcdir="${SRC_PATH}" destdir="${DES_CLASS_PATH}" encoding="UTF-8">
   <classpath refid="classpath" />
  </javac>
 </target>

 <!-- Copy发布 -->
 <target name="build" depends="init,compile">

  <copy todir="${DES_WEB_INF_PATH}" overwrite="true">
   <fileset dir="${WEB_PATH}/WEB-INF">
    <include name="**/*.tld" />
    <include name="**/*.xml" />
    <include name="**/*.properties" />
    <include name="**/*.txt" />
   </fileset>
  </copy>
  <copy todir="${DES_LIB_PATH}" overwrite="true">
   <fileset dir="${WEB_PATH}/WEB-INF/lib">
    <include name="*.jar" />
    <!--需要在部署说明文档中特别指出:应删除jboss-5.1.0.GA/common/lib目录下hibernate-validator.jar文件-->
    <exclude name="hibernate*.jar" />
    <exclude name="jetty*.jar" />
    <exclude name="servlet*.jar" />
    <exclude name="catalina.jar" />
    <!--<exclude name="mysql*.jar" />-->
   </fileset>
  </copy>
  <copy todir="${DES_CLASS_PATH}" overwrite="true">
   <fileset dir="${SRC_PATH}">
    <include name="**/*.tld" />
    <include name="**/*.xml" />
    <include name="**/*.properties" />
    <include name="**/*.txt" />
    <include name="**/*.dic" />
    <include name="**/*.jpg" />
    <include name="**/*.bmp" />
   </fileset>
  </copy>
  <copy todir="${DEPLOY_SQL_PATH}" overwrite="true">
   <fileset dir="${basedir}">
    <include name="*.sql" />
   </fileset>
  </copy>
  <copy todir="${DEPLOY_PATH}" overwrite="true">
   <fileset dir="${WEB_PATH}">    
    <exclude name="WEB-INF/lib/javaee.jar" />
   </fileset>
  </copy>
  <zip compress="false" destfile="${DEPLOY_ZIP_FILE}">
   <fileset dir="${basedir}/dist">
    <exclude name="**/*.zip" />
   </fileset>
  </zip>
  <delete dir="${DEPLOY_PATH}" />
 </target>
</project>