• ant 打war包


    <?xml version="1.0" ?>
    <project name="hp" default="war">
     <property name="src" value="src" />
     <property name="WebContent" value="WebContent" />
     <property name="dist" value="dist" />
     <property name="warDest" value="wardest" />
     <property name="classDest" value="class" />
     <property name="source-encoding" value="UTF-8" />
     <property name="tomcat-lib" value="d:/apache-tomcat-6.0.32/lib" />
     <property name="warName" value="ROOT.war"/>

     <!--编译java源文件所需的jar文件 -->
     <path id="build-classpath">
      <fileset dir="WebContent\WEB-INF\lib">
       <include name="*.jar" />
      </fileset>
      <fileset dir="${tomcat-lib}">
       <include name="*.jar" />
      </fileset>
     </path>
     
     <!--清理-->
     <target name="clean">
      <delete dir="${dist}" />
     </target>
     
     <!-- 初始化,建立相关的文件夹-->
     <target name="init">
      <mkdir dir="${dist}"/>
      <mkdir dir="${dist}/${warDest}" />
      <mkdir dir="${dist}/${classDest}" />
     </target>
     
     <!-- 编译java源文件并拷贝到相应的文件夹-->
     <target name="compile" depends="init">
      <javac srcdir="${src}" destdir="${dist}/${classDest}"  target="1.6"
       classpathref="build-classpath" encoding="${source-encoding}"
       debug="true" debuglevel="source,lines,vars">
      </javac>
     </target>
     
     <!--拷贝webcontent文件到相应的文件夹-->
     <target name="copy">
      <copy todir="${dist}/${warDest}">
       <fileset dir="${WebContent}">
        <exclude name="**/*.jar"/>
       </fileset>
      </copy>
      <copy todir="${dist}/${classDest}">
       <fileset dir="${src}">
        <exclude name="**/*.java"/>
       </fileset>
      </copy>
       
      <!--拷贝部署用的配置文件-->
      <delete file="${dist}/${warDest}/WEB-INF/config/log4j.properties"/>
      <move file="${dist}/${warDest}/WEB-INF/config/log4j.build.properties"
       tofile="${dist}/${warDest}/WEB-INF/config/log4j.properties" />
      <delete file="${dist}/${warDest}/WEB-INF/web.xml"/>
      <move file="${dist}/${warDest}/WEB-INF/web.build.xml"
       tofile="${dist}/${warDest}/WEB-INF/web.xml" />
      <delete file="${dist}/${warDest}/META-INF/context.xml"/>
       <move file="${dist}/${warDest}/META-INF/context.build.xml"
        tofile="${dist}/${warDest}/META-INF/context.xml" />
     </target>
     
     <!--打包-->
     <target name="war" depends="compile, copy">
      <war destfile="${dist}/${warName}" webxml="${WebContent}/WEB-INF/web.xml">
       <fileset dir="${dist}/${warDest}" />
       <!--
       <lib dir="${WebContent}/WEB-INF/lib"/>
       -->
       <classes dir="${dist}/${classDest}"></classes>
      </war>
      <delete dir="${dist}/${warDest}"></delete>
      <delete dir="${dist}/${classDest}"></delete>
     </target>
     
    </project>

  • 相关阅读:
    【从零开始学Java笔记】学生管理系统
    【从零开始学Java笔记】关键字super和this
    【从零开始学Java笔记】关键字Static
    【从零开始学Java笔记】关键字final
    【从零开始学Java笔记】关键字abstract
    循环结构
    switch选择结构
    if条件语句
    位运算
    Eclipse 报错The method xxx of type must override a superclass method、Description Resource Path Location Type Java compiler level does not match the version of the installed Java project facet
  • 原文地址:https://www.cnblogs.com/zhenmingliu/p/2355085.html
Copyright © 2020-2023  润新知