ANT工程打包文件

来源:互联网 发布:淘宝打假怎么套话 编辑:程序博客网 时间:2024/05/22 00:42

工作中经常用到ANT编译打包 虽然经常使用却不是经常写这些文件
现发一些上来 供平时看看 参考下 仔细看看就知道什么意思了
<project name="build_project" default="packaging">
<property name="ROOT" location="." />
<property name="SOURCE" location="${ROOT}/source" />
<property name="LIBRARY" location="${ROOT}/common_jar" />
<property name="WEBAPPS" location="${ROOT}/webapps" />
<property name="BUILD" location="${ROOT}/build" />

<path id="library.path">
 <fileset dir="${LIBRARY}">
  <include name="**/*.jar" />
 </fileset>
</path>

<target name="init">
 <delete dir="${BUILD}" />
</target>
<target name="prepare" depends="init">
 <echo message="preparing web app files....." />
 <copy todir="${BUILD}">
  <fileset dir="${WEBAPPS}">
   <include name="**/*.*" />
  </fileset>
 </copy>
 <mkdir dir="${BUILD}/WEB-INF/lib" />
 <copy todir="${BUILD}/WEB-INF/lib">
  <fileset dir="${LIBRARY}">
   <include name="*.jar" />
   <exclude name="servlet.jar" />
  </fileset>
 </copy>
</target>

<target name="compile" depends="prepare">
 <echo message="compiling source file......" />
 <javac
  srcdir="${SOURCE}"
  destdir="${SOURCE}"
  debug="off"
  optimize="off"
  deprecation="off"
  fork="yes">
  <classpath refid="library.path" />
 </javac>
 <echo message="making project jar file......." />
 <jar jarfile="${BUILD}/WEB-INF/lib/teleland.jar"
    filesonly="true"
    update="true"
    basedir="${SOURCE}"
    includes="**/*.class, **/*.properties" />
</target>

<target name="packaging" depends="compile" >
 <echo message="packaging files and create WAR ...." />
 <jar jarfile="teleland.war"
    filesonly="true"
    update="true"
    basedir="${BUILD}"
    includes="**/*.*" />
</target>

</project>