废话不多说,直接上代码
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- ======================================================================
- 2013-4-4 下午10:12:23
- project
- description
- kenan
- ====================================================================== -->
- <project name="project">
- <property name="build.dir" location="build"/>
- <property name="build.classes" location="${build.dir}/classes"/>
- <property name="build.war" location="${build.dir}/war"></property>
- <property name="web.root" value="WebContent"/>
- <property name="web.WEB-INF" value="${web.root}/WEB-INF"></property>
- <property name="web.jar" location="${web.WEB-INF}/lib"/>
- <!-- 引入环境变量 -->
- <property environment="env"></property>
- <path id="compile-path">
- <fileset dir="${web.jar}" includes="*.jar"></fileset>
- <fileset dir="D:\apache-tomcat-6.0.35\lib" includes="*.jar" ></fileset>
- </path>
- <target name="init">
- <delete dir="${build.dir}"></delete>
- <mkdir dir="${build.dir}"/>
- <mkdir dir="${build.classes}"/>
- <mkdir dir="${build.war}"/>
- </target>
- <target name="compile" depends="init">
- <javac encoding="GBK" destdir="${build.classes}" srcdir="src" classpathref="compile-path"></javac>
- </target>
- <target name="build-war" depends="compile">
- <war destfile="${build.war}/spring_mvc.war">
- <fileset dir="${web.root}" includes="**/*.*"></fileset>
- <classes dir="${build.classes}"></classes>
- <!--
- <lib dir="${web.jar}"></lib>
- <webinf dir="${web.WEB-INF}"></webinf>-->
- </war>
- </target>
- <!--操作数据库 命令预定义-->
- <presetdef name="mysql-admin">
- <sql driver="com.mysql.jdbc.Driver" password="root" url="jdbc:mysql://localhost:3306/?userUnicode=true&characterEncoding=utf-8" userid="root">
- <classpath>
- <fileset dir="D:\Workspaces\woyaoziyou\A_template_ssh_annotation_02_mysql\WebRoot\WEB-INF\lib" includes="mysql-*.jar"></fileset>
- </classpath>
- </sql>
- </presetdef>
- <target name="init-db">
- <mysql-admin>
- <transaction>
- create database ant_test;
- </transaction>
- </mysql-admin>
- </target>
- </project>
转载于:https://blog.51cto.com/soukenan/1171212