Ant-发布web项目和操作数据库

废话不多说,直接上代码

  
  
  
  
  1. <?xml version="1.0" encoding="UTF-8"?> 
  2. <!-- ======================================================================  
  3.      2013-4-4 下午10:12:23                                                         
  4.  
  5.      project     
  6.      description 
  7.                     
  8.      kenan                                                                 
  9.      ====================================================================== --> 
  10. <project name="project"> 
  11.         <property name="build.dir" location="build"/> 
  12.         <property name="build.classes" location="${build.dir}/classes"/> 
  13.         <property name="build.war" location="${build.dir}/war"></property> 
  14.      
  15.         <property name="web.root" value="WebContent"/> 
  16.         <property name="web.WEB-INF" value="${web.root}/WEB-INF"></property> 
  17.         <property name="web.jar" location="${web.WEB-INF}/lib"/> 
  18.  
  19.         <!-- 引入环境变量 --> 
  20.         <property environment="env"></property> 
  21.         <path id="compile-path"> 
  22.             <fileset dir="${web.jar}" includes="*.jar"></fileset> 
  23.             <fileset dir="D:\apache-tomcat-6.0.35\lib" includes="*.jar" ></fileset> 
  24.         </path> 
  25.         <target name="init"> 
  26.             <delete dir="${build.dir}"></delete> 
  27.             <mkdir dir="${build.dir}"/> 
  28.             <mkdir dir="${build.classes}"/> 
  29.             <mkdir dir="${build.war}"/> 
  30.         </target> 
  31.      
  32.         <target name="compile" depends="init"> 
  33.             <javac encoding="GBK" destdir="${build.classes}" srcdir="src" classpathref="compile-path"></javac> 
  34.         </target> 
  35.  
  36.         <target name="build-war" depends="compile"> 
  37.             <war destfile="${build.war}/spring_mvc.war"> 
  38.                 <fileset dir="${web.root}" includes="**/*.*"></fileset> 
  39.                 <classes dir="${build.classes}"></classes> 
  40.                 <!-- 
  41.                 <lib dir="${web.jar}"></lib> 
  42.                 <webinf dir="${web.WEB-INF}"></webinf>--> 
  43.             </war> 
  44.         </target> 
  45.      
  46.     <!--操作数据库  命令预定义--> 
  47.     <presetdef name="mysql-admin"> 
  48.         <sql driver="com.mysql.jdbc.Driver" password="root" url="jdbc:mysql://localhost:3306/?userUnicode=true&amp;characterEncoding=utf-8" userid="root"> 
  49.             <classpath> 
  50.                 <fileset dir="D:\Workspaces\woyaoziyou\A_template_ssh_annotation_02_mysql\WebRoot\WEB-INF\lib" includes="mysql-*.jar"></fileset> 
  51.             </classpath> 
  52.         </sql> 
  53.     </presetdef> 
  54.     <target name="init-db"> 
  55.         <mysql-admin> 
  56.             <transaction> 
  57.                 create database ant_test;  
  58.             </transaction> 
  59.         </mysql-admin> 
  60.     </target> 
  61. </project> 

 

你可能感兴趣的:(sql,ant,命令预定义,preset)