ANT工程配置

ANT工程配置

通用的ANT的build.xml文件,以备后用。

Java代码
  1. <project name= "hnwt114"   default = "build"  basedir= "." >  
  2.     <!-- 工程根目录 -->  
  3.     <property name="hnwt144.home"  value= "." />  
  4.     <!-- 工程根名 -->  
  5.     <property name="hnwt144.name"  value= "HNWT114" />  
  6.     <!-- tomcat路径 -->  
  7.     <property name="tomcat.home"  value= "D:/apache-tomcat-5.5.26" />  
  8.     <!-- tomcat部署路径 -->  
  9.     <property name="webapps.home"  value= "${tomcat.home}/webapps" />  
  10.     <!-- JAVA源文件路径 -->  
  11.     <property name="src.home"  value= "${hnwt144.home}/src" />  
  12.       
  13.     <!-- class 文件存放位置 -->  
  14.     <property name="classes.home"  value= "${hnwt144.home}/classes" />  
  15.     <!-- 发布文件夹 -->  
  16.     <property name="deploy.home"  value= "${hnwt144.home}/deploy" />  
  17.     <!-- webRoot路径 -->  
  18.     <property name="web.home"  value= "${hnwt144.home}/webRoot" />  
  19.       
  20.     <!-- 创建工程路径 -->  
  21.     <property name="build.home"  value= "${hnwt144.home}/build" />  
  22.     <!-- /WEB-INF/classes -->  
  23.     <property name="build.classes"  value= "${hnwt144.home}/WEB-INF/classes" />  
  24.     <!-- /WEB-INF/lib -->  
  25.     <property name="build.lib"  value= "${hnwt144.home}/WEB-INF/lib" />  
  26.     <!-- 工程引用包 -->  
  27.     <property name="lib.home"  value= "${web.home}/WEB-INF/lib" />  
  28.       
  29.       
  30.     <!-- 编译工程所需的JAR包 -->  
  31.     <path id="compile.classpath" >  
  32.         <pathelement location="${classes.home}" />  
  33.         <fileset dir="${lib.home}" >  
  34.                 <include name="*.jar" />  
  35.                 <include name="*.zip" />  
  36.         </fileset>  
  37.         <fileset dir="${tomcat.home}/common/lib" >  
  38.             <include name="*.jar" />  
  39.         </fileset>  
  40.         <pathelement location="${tomcat.home}/common/classes" />  
  41.     </path>  
  42.       
  43.       
  44.     <!-- 测试ANT -->  
  45.     <target name="help" >  
  46.         <echo message="Please specify a target![usage:ant&lt;targetname&gt;]" />  
  47.         <echo message="Here is a list of possible targets:" />  
  48.         <echo message="  clean-all....Delete build dir,all .class and war files" />  
  49.         <echo message="  perpare....Creates directories if requied" />  
  50.         <echo message="  compile....Compiles source files" />  
  51.         <echo message="  build......Build war file from.class and other files" />  
  52.         <echo message="  deploy......Copy war file to the webapps directory" />  
  53.     </target>  
  54.       
  55.       
  56.     <!-- 清除 -->  
  57.     <target name="clean-all" >  
  58.         <delete dir="${build.home}" />  
  59.         <delete dir="${classes.home}" />  
  60.         <delete dir="${deploy.home}" />  
  61.           
  62.         <delete dir="${webapps.home}/${hnwt114.home}"  failοnerrοr= "false" />  
  63.         <delete dir="${webapps.home}/${hnwt114.name}.war" />  
  64.     </target>  
  65.       
  66.       
  67.     <!-- 准备工作 -->  
  68.     <target name="prepare" >  
  69.         <echo message="Tomcat Home=${tomcat.home}" />  
  70.         <echo message="Webapps Home=${webapps.home}" />  
  71.           
  72.         <mkdir dir="${classes.home}" />  
  73.         <mkdir dir="${deploy.home}" />       
  74.           
  75.         <mkdir dir="${build.home}" />  
  76.         <mkdir dir="${build.home}/WEB-INF" />  
  77.         <mkdir dir="${build.home}/WEB-INF/classes" />  
  78.         <mkdir dir="${build.home}/WEB-INF/lib" />  
  79.     </target>  
  80.       
  81.       
  82.     <!-- 编译 -->  
  83.     <target name="compile"  depends= "prepare" >  
  84.         <javac srcdir="${src.home}"  destdir= "${classes.home}"  debug= "no" >  
  85.             <classpath refid="compile.classpath" />  
  86.         </javac>  
  87.     </target>  
  88.       
  89.     <!-- 构建临时工程 -->  
  90.     <target name="build"  depends= "compile" >  
  91.         <copy todir="${build.home}" >  
  92.             <fileset dir="${web.home}" />  
  93.         </copy>  
  94.         <copy todir="${build.home}/WEB-INF/classes" >  
  95.             <fileset dir="${classes.home}" />  
  96.         </copy>  
  97.           
  98.         <copy todir="${build.home}/WEB-INF/classes" >  
  99.             <fileset dir="${src.home}" >  
  100.                 <include name="**/*.properties" />  
  101.                 <include name="**/*.prop" />  
  102.             </fileset>  
  103.         </copy>  
  104.           
  105.         <jar jarfile="${deploy.home}/${hnwt144.name}.war"  basedir= "${build.home}" />  
  106.     </target>  
  107.     <!-- 发布 -->  
  108.     <target name="deploy"  depends= "build" >  
  109.         <copy todir="${webapps.home}"  file= "${deploy.home}/${hnwt144.name}.war" />  
  110.     </target>  
  111.           
  112.     </project> 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值